@webticks/next
v0.2.1
Published
Next.js integration for WebTicks analytics
Readme
@webticks/next
Next.js integration for WebTicks analytics.
Installation
npm install @webticks/nextQuick Start
App Router
Add to your root layout with explicit configuration:
// app/layout.tsx
import WebticksAnalytics from '@webticks/next';
export default function RootLayout({ children }) {
return (
<html>
<body>
<WebticksAnalytics
serverUrl="https://your-api.com/track"
appId="your-app-id"
/>
{children}
</body>
</html>
);
}Best Practices: Environment Variables
For security and flexibility, it is highly recommended to source your configuration from environment variables rather than hardcoding them.
In Next.js, make sure to prefix your variables with NEXT_PUBLIC_ to make them available in the browser.
<WebticksAnalytics
serverUrl={process.env.NEXT_PUBLIC_WEBTICKS_SERVER_URL}
appId={process.env.NEXT_PUBLIC_WEBTICKS_APP_ID}
/>Props
| Prop | Type | Description |
|------|------|-------------|
| serverUrl | string | Recommended. URL to send analytics. Defaults to /api/track. |
| appId | string | Required. Your application ID. |
| debug | boolean | Optional. Enable console logging. Defaults to false. |
[!NOTE]
appIdandserverUrlare typically provided by the webticks-api project, which you can self-host. Alternatively, you can use any backend that implements the WebTicks ingestion API.
