A library for integrating shynet into your next.js project.
It helps to easily use shynet in a single page application. The library also has declarations for typescript.
Install this library:
npm install next-shynet
Change your app/layout.tsx
:
import { ShynetForAppRouter } from "next-shynet"
export default async function RootLayout({children}) {
return (
<html>
<body>
<ShynetForAppRouter
scriptSrc="https://your-shynet-instance/.../index.js"
imgSrc="https://your-shynet-instance/.../pixel.gif"
/>
</body>
</html>
)
}
Change your _app.js
:
import Shynet from "next-shynet"
const YourApp = ({ Component, pageProps }) => (
<div>
<Shynet
scriptSrc="https://your-shynet-instance/.../index.js"
imgSrc="https://your-shynet-instance/.../pixel.gif" />
<Component {...pageProps} />
</div>
)
The link to the tracking pixel is optional.
By default, the script is not loaded during development.
To force the script to be included, add the ignoreEnv
option:
<Shynet scriptSrc="" ignoreEnv />
npm install
npm run build
The generated files will be in the /dist
directory.
- Ivan Reshetnikov ordinarydev@protonmail.com