analyts
v1.0.0
Published
Lightweight, privacy-first analytics tracker for React, Next.js, and vanilla JS. No cookies, no personal data — just page views.
Maintainers
Readme
analyts
Lightweight, privacy-first analytics for your website. No cookies, no personal data — just page views.
Installation
npm install analytsUsage
Next.js (App Router)
// app/layout.tsx
import { WebAnalytsScript } from 'analyts/next'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<WebAnalytsScript domain="mysite.com" />
{children}
</body>
</html>
)
}React (Vite, CRA, etc.)
import { WebAnalyts } from 'analyts'
function App() {
return (
<>
<WebAnalyts domain="mysite.com" />
<YourApp />
</>
)
}Vanilla JavaScript
import { init } from 'analyts'
init({ domain: 'mysite.com' })HTML Script Tag
If you prefer not to use npm, add this to your HTML:
<script defer data-domain="mysite.com" src="https://webanalyts.vercel.app/script.js"></script>API
<WebAnalytsScript /> (Next.js)
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| domain | string | required | Your site's domain |
| src | string | Hosted script URL | Custom script source |
| strategy | 'afterInteractive' \| 'lazyOnload' \| 'worker' | 'afterInteractive' | Next.js script loading strategy |
<WebAnalyts /> (React)
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| domain | string | required | Your site's domain |
| src | string | Hosted script URL | Custom script source |
init(config) (Vanilla JS)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| domain | string | required | Your site's domain |
| src | string | Hosted script URL | Custom script source |
Self-Hosting
If you're self-hosting WebAnalyts, point src to your own instance:
<WebAnalytsScript domain="mysite.com" src="https://your-instance.com/script.js" />License
MIT
