Add rustalytics to your Next.js app in under 5 minutes
npm install @rustalytics/next
1. Create a new middleware.ts file in your project root (or edit if it exists):
// middleware.ts
import { RustalyticMiddleware } from '@rustalytics/next'
export const config = {
matcher: '/:path*',
}
export default RustalyticMiddleware({
projectId: 'your-project-id'
})
2. Track custom events (optional):
// any component
import { track } from '@rustalytics/next'
// Track an event
track('button_clicked', {
buttonId: 'signup',
page: 'homepage'
})
Your rustalytics project ID (required)
Optional domain to restrict tracking to
Array of paths to exclude from tracking
If you need any help with the integration, feel free to: