Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
/ next-shynet Public archive

A library for integrating Shynet (self-hosted privacy-friendly web analytics) into your next.js project.

License

Notifications You must be signed in to change notification settings

ordinary-dev/next-shynet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next-Shynet

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.

Usage

Install this library:

npm install next-shynet

App router

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>
    )
}

Pages router

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 />

How to build

npm install
npm run build

The generated files will be in the /dist directory.

Authors