Next.js Integration

Add rustalytics to your Next.js app in under 5 minutes

Installation

npm install @rustalytics/next

Usage

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

Configuration Options

projectId *

Your rustalytics project ID (required)

domain

Optional domain to restrict tracking to

excludePaths

Array of paths to exclude from tracking

Need Help?

If you need any help with the integration, feel free to: