@swetrix/nextjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Swetrix Next.js integration

Official Swetrix Analytics integration for Next.js.

Integration

Install

Run the following command to install in your project:

npm install @swetrix/nextjs

Or with yarn:

yarn add @swetrix/nextjs

Basic usage

You can now import, and use the Swetrix hook on your project:

// ./pages/_app.js

import { useSwetrix } from '@swetrix/nextjs'

function YourApp({ Component, pageProps }) {
  useSwetrix('YOUR_PROJECT_ID')

  return <Component {...pageProps} />
}

export default YourApp

Debug-mode

When developing in localhost, Swetrix does not send events to avoid using your quota.
You can enable debug mode to send events when testing things locally. It will also log messages to console.

// ./pages/_app.js

import { useSwetrix } from '@swetrix/nextjs'

function YourApp({ Component, pageProps }) {
  useSwetrix('YOUR_SITE_ID', {
    debug: true
  })

  return <Component {...pageProps} />
}

export default YourApp

Advanced options

useSwetrix hook accepts 3 parameters: PID, initOptions, pageViewsOptions.
See our documentation page for more details.
You can always contact us in case of any questions! :)

Contribution

Feel free to contribute to the source code by opening a pull requests.
For any questions, you can open an issue ticket, refer to our FAQs page or reach us at contact@swetrix.com \

Selfhosted API

If you are selfhosting the Swetrix-API, be sure to point the apiUrl parameter to: https://yourapiinstance.com/log

Donate

You can support the project by donating us at https://ko-fi.com/andriir
We can only run our services by once again asking for your financial support!

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.11latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.11
1.0.00

Package Sidebar

Install

npm i @swetrix/nextjs

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

8.87 kB

Total Files

6

Last publish

Collaborators

  • blaumaus