@siteline/nextjs
v1.0.1
Published
Official Next.js integration for Siteline - automatic AI agent and bot tracking with zero configuration
Readme
@siteline/nextjs
Official Next.js integration for automatic AI agent and bot tracking.
Features
- Zero-config middleware for automatic tracking
- Track bots from OpenAI, Google, Anthropic, Perplexity, and more
- Works in Edge Runtime and Node.js
- Full TypeScript support
- Compatible with App Router and Pages Router
- Extensible with custom middleware
Installation
npm install @siteline/nextjsQuick Start
Without Custom Proxy (ex Middleware)
// proxy.ts
import { withSiteline } from '@siteline/nextjs';
export default withSiteline({
websiteKey: process.env.SITELINE_WEBSITE_KEY!,
});
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};With Custom Proxy (ex Middleware)
// proxy.ts
import { type SitelineConfig, withSiteline } from '@siteline/nextjs';
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
const sitelineConfig: SitelineConfig = {
websiteKey: process.env.SITELINE_WEBSITE_KEY!,
debug: process.env.NODE_ENV === 'development',
}
export default withSiteline(sitelineConfig, (request: NextRequest) => {
const response = NextResponse.next();
response.headers.set('x-custom-header', 'value');
return response;
});
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};Configuration
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| websiteKey | string | Yes* | Your Siteline website key (*or set via SITELINE_WEBSITE_KEY env var) |
| endpoint | string | No | Custom API endpoint |
| debug | boolean | No | Enable debug logging |
Environment Variables
# .env.local
SITELINE_WEBSITE_KEY=siteline_secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
SITELINE_ENDPOINT=https://api.siteline.ai/v1/intake/pageview # Optional
SITELINE_DEBUG=true # OptionalDocumentation
Related Packages
- @siteline/core - Core tracking SDK
Support
License
MIT
