@tsparticles/vue3
v4.0.5
Published
Official tsParticles Vue.js 3.x Component - Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for Web Components, React, Vue.js 2.x,
Keywords
Readme
@tsparticles/vue3
Official Vue 3 component wrapper for tsParticles.
Installation
pnpm add @tsparticles/vue3 @tsparticles/engineUsage
Register the plugin once in your app and provide your own async init function.
import { createApp } from "vue";
import Particles from "@tsparticles/vue3";
import type { Engine } from "@tsparticles/engine";
import App from "./App.vue";
async function registerParticles(engine: Engine): Promise<void> {
const [{ loadSlim }] = await Promise.all([import("@tsparticles/slim")]);
await loadSlim(engine);
}
const app = createApp(App);
app.use(Particles, {
init: registerParticles,
});
app.mount("#app");Then use the component anywhere in the app:
<template>
<vue-particles id="tsparticles" :options="options" @particles-loaded="particlesLoaded" />
</template>
<script setup lang="ts">
import type { Container, ISourceOptions } from "@tsparticles/engine";
const options: ISourceOptions = {
particles: {
number: { value: 80 },
links: { enable: true },
move: { enable: true },
},
};
function particlesLoaded(container?: Container): void {
console.log("Particles loaded", container);
}
</script>How init works
initis called once per Vue app instance.- Components wait for
initcompletion before loading. - You choose what to import inside
init(@tsparticles/slim,tsparticles, custom plugins, etc.).
Nuxt support
For Nuxt projects use @tsparticles/nuxt3 or @tsparticles/nuxt4, which wrap this package in a Nuxt module.

