@tsparticles/nextjs 4.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.js +15 -0
- package/dist/lib/index.d.ts +8 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Matteo Bruni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# @tsparticles/nextjs
|
|
4
|
+
|
|
5
|
+
Next.js integration wrapper for [@tsparticles/react](https://www.npmjs.com/package/@tsparticles/react).
|
|
6
|
+
|
|
7
|
+
## Why this package
|
|
8
|
+
|
|
9
|
+
- Provides Next.js-first exports (`NextParticlesProvider`, `NextParticles`).
|
|
10
|
+
- Handles client-only rendering for particles via dynamic import.
|
|
11
|
+
- Keeps the one-time async init flow centered on the provider.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @tsparticles/nextjs @tsparticles/react @tsparticles/engine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @tsparticles/nextjs @tsparticles/react @tsparticles/engine
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
or
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @tsparticles/nextjs @tsparticles/react @tsparticles/engine
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage (App Router)
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
"use client";
|
|
35
|
+
|
|
36
|
+
import { NextParticles, NextParticlesProvider } from "@tsparticles/nextjs";
|
|
37
|
+
import type { Engine } from "@tsparticles/engine";
|
|
38
|
+
|
|
39
|
+
const init = async (engine: Engine): Promise<void> => {
|
|
40
|
+
const [{ loadSlim }, { loadThemesPlugin }] = await Promise.all([
|
|
41
|
+
import("@tsparticles/slim"),
|
|
42
|
+
import("@tsparticles/plugin-themes"),
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
await Promise.all([loadSlim(engine), loadThemesPlugin(engine)]);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default function Page() {
|
|
49
|
+
return (
|
|
50
|
+
<NextParticlesProvider init={init}>
|
|
51
|
+
<NextParticles id="tsparticles" options={{ fullScreen: { zIndex: -1 } }} />
|
|
52
|
+
</NextParticlesProvider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage (Pages Router)
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import type { AppProps } from "next/app";
|
|
61
|
+
import { NextParticlesProvider } from "@tsparticles/nextjs";
|
|
62
|
+
import type { Engine } from "@tsparticles/engine";
|
|
63
|
+
|
|
64
|
+
const init = async (engine: Engine): Promise<void> => {
|
|
65
|
+
const [{ loadSlim }, { loadThemesPlugin }] = await Promise.all([
|
|
66
|
+
import("@tsparticles/slim"),
|
|
67
|
+
import("@tsparticles/plugin-themes"),
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
await Promise.all([loadSlim(engine), loadThemesPlugin(engine)]);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
74
|
+
return (
|
|
75
|
+
<NextParticlesProvider init={init}>
|
|
76
|
+
<Component {...pageProps} />
|
|
77
|
+
</NextParticlesProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "next/dynamic";
|
|
3
|
+
import { ParticlesProvider as t } from "@tsparticles/react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/index.tsx
|
|
6
|
+
var r = e(() => import("@tsparticles/react").then((e) => e.Particles), { ssr: !1 });
|
|
7
|
+
function i({ children: e, init: r }) {
|
|
8
|
+
return /* @__PURE__ */ n(t, {
|
|
9
|
+
init: r,
|
|
10
|
+
children: e
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var a = r;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { a as NextParticles, i as NextParticlesProvider };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { IParticlesProps, ParticlesPluginRegistrar } from '@tsparticles/react';
|
|
3
|
+
export type { IParticlesProps, ParticlesPluginRegistrar };
|
|
4
|
+
export interface INextParticlesProviderProps extends PropsWithChildren {
|
|
5
|
+
init: ParticlesPluginRegistrar;
|
|
6
|
+
}
|
|
7
|
+
export declare function NextParticlesProvider({ children, init }: INextParticlesProviderProps): ReactNode;
|
|
8
|
+
export declare const NextParticles: ComponentType<IParticlesProps>;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/nextjs",
|
|
3
|
+
"version": "4.0.0-beta.12",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "prettier --write README.md && pnpm run prettify && tsc && vite build",
|
|
10
|
+
"build:ci": "prettier --check README.md && pnpm run prettify:ci && tsc && vite build",
|
|
11
|
+
"lint": "eslint . --max-warnings 0",
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
"prettify": "prettier --write \"src/**/*.{ts,tsx}\" && prettier --write \"lib/**/*.{ts,tsx}\"",
|
|
14
|
+
"prettify:ci": "prettier --check \"src/**/*.{ts,tsx}\" && prettier --check \"lib/**/*.{ts,tsx}\"",
|
|
15
|
+
"prepublishOnly": "pnpm run build"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@tsparticles/react": ">=3.0.0",
|
|
29
|
+
"next": ">=13.0.0",
|
|
30
|
+
"react": ">=18.0.0",
|
|
31
|
+
"react-dom": ">=18.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tsparticles/react": "^4.0.0-beta.12",
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
38
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
39
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
40
|
+
"eslint": "^10.2.0",
|
|
41
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
42
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
43
|
+
"glob": "^13.0.6",
|
|
44
|
+
"next": "^16.2.3",
|
|
45
|
+
"react": "^19.2.5",
|
|
46
|
+
"react-dom": "^19.2.5",
|
|
47
|
+
"typescript": "^6.0.2",
|
|
48
|
+
"vite": "^8.0.8",
|
|
49
|
+
"vite-plugin-dts": "^4.5.4"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "bdbc95716ce44665fbecfaca8757445e248b562d"
|
|
55
|
+
}
|