1 | [](https://particles.js.org)
|
2 |
|
3 | # tsParticles Full Bundle
|
4 |
|
5 | [](https://www.jsdelivr.com/package/npm/tsparticles) [](https://www.npmjs.com/package/tsparticles) [](https://www.npmjs.com/package/tsparticles) [](https://github.com/sponsors/matteobruni)
|
6 |
|
7 | [tsParticles](https://github.com/matteobruni/tsparticles) full bundle loads all the v1 features to
|
8 | a `tsparticles-engine` instance.
|
9 |
|
10 | **Included Packages**
|
11 |
|
12 | - [tsparticles-engine](https://github.com/matteobruni/tsparticles/tree/main/engine)
|
13 | - [tsparticles-slim (and all its dependencies)](https://github.com/matteobruni/tsparticles/tree/main/bundles/slim)
|
14 | - [tsparticles-interaction-external-trail](https://github.com/matteobruni/tsparticles/tree/main/interactions/external/trail)
|
15 | - [tsparticles-plugin-absorbers](https://github.com/matteobruni/tsparticles/tree/main/plugins/absorbers)
|
16 | - [tsparticles-plugin-emitters](https://github.com/matteobruni/tsparticles/tree/main/plugins/emitters)
|
17 | - [tsparticles-updater-roll](https://github.com/matteobruni/tsparticles/tree/main/updaters/roll)
|
18 | - [tsparticles-updater-tilt](https://github.com/matteobruni/tsparticles/tree/main/updaters/tilt)
|
19 | - [tsparticles-updater-wobble](https://github.com/matteobruni/tsparticles/tree/main/updaters/wobble)
|
20 |
|
21 | ## How to use it
|
22 |
|
23 | ### CDN / Vanilla JS / jQuery
|
24 |
|
25 | The CDN/Vanilla version JS has two different files:
|
26 |
|
27 | - One is a bundle file with all the scripts included in a single file
|
28 | - One is a file including just the `loadFull` function to load the tsParticles full preset, all dependencies must be
|
29 | included manually
|
30 |
|
31 | #### Bundle
|
32 |
|
33 | Including the `tsparticles.bundle.min.js` file will work exactly like `v1`, you can start using the `tsParticles`
|
34 | instance in the same way.
|
35 |
|
36 | This is the easiest usage, since it's a single file with the same `v1` features.
|
37 |
|
38 | All new features will be added as external packages, this bundle is recommended for migrating from `v1` easily.
|
39 |
|
40 | #### Not Bundle
|
41 |
|
42 | This installation requires more work since all dependencies must be included in the page. Some lines above are all
|
43 | specified in the **Included Packages** section.
|
44 |
|
45 | A note about `tsparticles-slim` can be made: it's not mandatory to include all of its dependencies, the slim bundle file
|
46 | is enough, and if this is done the `tsparticles-engine` is not needed, since it's already bundled in the slim bundle.
|
47 |
|
48 | ### Usage
|
49 |
|
50 | Once the scripts are loaded you can set up `tsParticles` like this:
|
51 |
|
52 | ```javascript
|
53 | (async () => {
|
54 | await loadFull(tsParticles); // not needed if using the bundle script, required for any other installation
|
55 |
|
56 | await tsParticles.load("tsparticles", {
|
57 | /* options */
|
58 | });
|
59 | })();
|
60 | ```
|
61 |
|
62 | ### React.js / Preact / Inferno
|
63 |
|
64 | _The syntax for `React.js`, `Preact` and `Inferno` is the same_.
|
65 |
|
66 | This sample uses the class component syntax, but you can use hooks as well (if the library supports it).
|
67 |
|
68 | _Class Components_
|
69 |
|
70 | ```typescript jsx
|
71 | import React from "react";
|
72 | import Particles from "react-particles";
|
73 | import type { Engine } from "tsparticles-engine";
|
74 | import { loadFull } from "tsparticles";
|
75 |
|
76 | export class ParticlesContainer extends PureComponent<unknown> {
|
77 | // this customizes the component tsParticles installation
|
78 | async customInit(engine: Engine): Promise<void> {
|
79 | // this adds the bundle to tsParticles
|
80 | await loadFull(engine);
|
81 | }
|
82 |
|
83 | render() {
|
84 | const options = {
|
85 | /* custom options */
|
86 | };
|
87 |
|
88 | return <Particles options={options} init={this.customInit} />;
|
89 | }
|
90 | }
|
91 | ```
|
92 |
|
93 | _Hooks / Functional Components_
|
94 |
|
95 | ```typescript jsx
|
96 | import React, { useCallback } from "react";
|
97 | import Particles from "react-particles";
|
98 | import type { Engine } from "tsparticles-engine";
|
99 | import { loadFull } from "tsparticles";
|
100 |
|
101 | export function ParticlesContainer(props: unknown) {
|
102 | // this customizes the component tsParticles installation
|
103 | const customInit = useCallback(async (engine: Engine) => {
|
104 | // this adds the bundle to tsParticles
|
105 | await loadFull(engine);
|
106 | });
|
107 |
|
108 | const options = {
|
109 | /* custom options */
|
110 | };
|
111 |
|
112 | return <Particles options={options} init={this.customInit} />;
|
113 | }
|
114 | ```
|
115 |
|
116 | ### Vue (2.x and 3.x)
|
117 |
|
118 | _The syntax for `Vue.js 2.x` and `3.x` is the same_
|
119 |
|
120 | ```vue
|
121 | <Particles id="tsparticles" :particlesInit="particlesInit" :options="options" />
|
122 | ```
|
123 |
|
124 | ```js
|
125 | const options = {
|
126 | /* custom options */
|
127 | };
|
128 |
|
129 | async function particlesInit(engine: Engine): Promise<void> {
|
130 | await loadFull(engine);
|
131 | }
|
132 | ```
|
133 |
|
134 | ### Angular
|
135 |
|
136 | ```html
|
137 | <ng-particles [id]="id" [options]="options" [particlesInit]="particlesInit"></ng-particles>
|
138 | ```
|
139 |
|
140 | ```ts
|
141 | const options = {
|
142 | /* custom options */
|
143 | };
|
144 |
|
145 | async function particlesInit(engine: Engine): Promise<void> {
|
146 | await loadFull(engine);
|
147 | }
|
148 | ```
|
149 |
|
150 | ### Svelte
|
151 |
|
152 | ```sveltehtml
|
153 |
|
154 | <Particles
|
155 | id="tsparticles"
|
156 | options={options}
|
157 | particlesInit={particlesInit}
|
158 | />
|
159 | ```
|
160 |
|
161 | ```js
|
162 | let options = {
|
163 | /* custom options */
|
164 | };
|
165 |
|
166 | let particlesInit = async (engine) => {
|
167 | await loadFull(engine);
|
168 | };
|
169 | ```
|