tsParticles particles bundle to create simple particle effects with a focused API.
Included Packages
The package API is centered on particles.
import { particles } from "@tsparticles/particles";
// Main API
const instance = await particles();
const byId = await particles("canvas-id", options);
const byOptions = await particles(options);
// Extra helpers
await particles.init();
const custom = await particles.create(canvas, options);
console.log(particles.version);
@tsparticles/particles does not expose tsParticles from its main entrypoint.
If you need direct engine APIs, import them from @tsparticles/engine.
pnpm add @tsparticles/particles
Lazy entrypoint (loads dependencies on demand):
import { particles } from "@tsparticles/particles/lazy";
import { particles } from "@tsparticles/particles";
const instance = await particles({
count: 120,
color: "#00f",
links: true,
linksColor: "#0ff",
linksLength: 140,
radius: 4,
shape: ["circle", "square"],
});
instance?.pause();
instance?.play();
instance?.stop();
particles.createimport { particles } from "@tsparticles/particles";
const canvas = document.getElementById("my-canvas") as HTMLCanvasElement;
await particles.create(canvas, { links: true });
Main options (shallow overview):
count Number: particles amount (default: 80)radius Number or RangeValue: particle radius (default: 3)links Boolean: enable links between particleslinksLength Number: maximum link distancespeed Number or RangeValue: particle movement speedcollisions Boolean: enable particle collisionsopacity Number: particle opacityshape String or Array<String>: particle shape type(s)color String: particle colorlinksColor String: link colorThe resolved ParticlesInstance exposes:
pause()play()stop()particles before scripts are loaded in CDN usagetsParticles is exported by @tsparticles/particles main entrypointid unintentionally (the package caches instances by id)