OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
{
"slug": "nextjs",
"audience": "nextjs",
"seo": {
"title": "Next.js Analytics, OpenPanel SDK for App Router & Pages Router",
"description": "Add analytics to your Next.js app in minutes. OpenPanel's Next.js SDK tracks route changes in the App Router and Pages Router, sends server-side events with the Node SDK, and proxies through your own domain. Open source, cookieless, from $2.50/month.",
"noindex": false
},
"hero": {
"heading": "Analytics built for Next.js",
"subheading": "OpenPanel ships a Next.js SDK that fits how Next.js works: one component in the root layout, route changes tracked in the App Router and the Pages Router, server-side events from Route Handlers and Server Actions, and a proxy route so ad blockers do not eat your data. Events, funnels and profiles that work with SSR.",
"badges": [
"App Router and Pages Router",
"Server-side events",
"Auto route tracking",
"3 KB client script"
]
},
"problem": {
"title": "Why standard analytics breaks in Next.js",
"intro": "Next.js is not a traditional website. Most analytics tools were built before App Router existed and show it.",
"items": [
{
"title": "GA4 breaks with App Router route changes",
"description": "Google Analytics was designed for traditional page loads. In Next.js App Router, client-side navigation doesn't trigger GA4's page view events unless you add custom workarounds. Your analytics misses a significant portion of page views."
},
{
"title": "Cookie consent is painful in Next.js",
"description": "Implementing a GDPR-compliant cookie consent flow in a Next.js app requires next/script, consent state management, and conditional script loading. It's a non-trivial engineering task just to run analytics."
},
{
"title": "No server-side tracking",
"description": "Most analytics SDKs are client-only. Server-side events, API route completions, background jobs, server actions, are invisible. You're missing half the picture."
},
{
"title": "Analytics libraries bloat your bundle",
"description": "Many analytics SDKs add 20 to 50 KB to your JavaScript bundle. In a performance-conscious Next.js app that shows up in Core Web Vitals."
}
]
},
"features": {
"title": "Analytics that works the way Next.js works",
"intro": "OpenPanel's Next.js SDK is a thin layer over the web SDK and the Node SDK, so it fits modern Next.js patterns without a client-only afterthought.",
"items": [
{
"title": "Next.js SDK with App Router support",
"description": "Install @openpanel/nextjs, add <OpenPanelComponent clientId=\"…\" trackScreenViews /> to your root layout, and page views are tracked in the App Router and the Pages Router."
},
{
"title": "Automatic route change tracking",
"description": "Every router.push(), <Link> navigation and back or forward action becomes a screen_view. The SDK hooks pushState, replaceState and popstate; no useEffect or router listeners needed."
},
{
"title": "Server-side event tracking",
"description": "Create an OpenPanel instance with your client id and secret in a Route Handler, Server Action or background job and call track(), identify() or revenue(). Payments and jobs land in the same project as the client events."
},
{
"title": "Proxy through your own domain",
"description": "Export createRouteHandler from @openpanel/nextjs/server in an API route and the script and events go through your domain. Ad blockers that block third-party analytics hosts no longer drop your data."
},
{
"title": "Cookieless by default",
"description": "No cookies, no localStorage, so no consent manager, no conditional script loading and no next/script gymnastics. Install and track."
},
{
"title": "Identify users across sessions",
"description": "Call identify({ profileId, email, firstName }) after sign-in, or pass profileId to the component when you have it on the server. Works with NextAuth.js, Clerk or your own auth."
},
{
"title": "TypeScript SDK",
"description": "The SDK is written in TypeScript with full types for every method, hook and component."
},
{
"title": "3 KB client script",
"description": "The tracker is about 3 KB gzipped and loads async after your page. Session replay is a separate module that loads only when enabled."
}
]
},
"benefits": {
"title": "Why Next.js developers choose OpenPanel",
"intro": "OpenPanel fits naturally into a modern Next.js codebase, not as an afterthought.",
"items": [
{
"title": "Works exactly how Next.js works",
"description": "One component for the client, the Node SDK for the server, a route handler for the proxy. Built on the same SDKs, not bolted onto a client-only library."
},
{
"title": "No consent infrastructure needed",
"description": "Cookieless tracking means no consent modal, no next/script loading gymnastics, no conditional initialization. Install once, works everywhere."
},
{
"title": "Track server and client events in the same dashboard",
"description": "Server Actions, Route Handlers and client interactions show up together, on the same profiles and in the same funnels."
},
{
"title": "Open source and self-hostable",
"description": "Run OpenPanel on your own infrastructure. Your Next.js app's analytics data never leaves your servers."
},
{
"title": "From $2.50/month",
"description": "No enterprise contract, no per-seat fees. Pay for events, get every feature. 30-day free trial on Cloud, free to self-host."
}
]
},
"faqs": {
"title": "Frequently asked questions",
"intro": "Common questions from Next.js developers evaluating OpenPanel.",
"items": [
{
"question": "How do I install OpenPanel in a Next.js app?",
"answer": "Install @openpanel/nextjs, add <OpenPanelComponent clientId=\"…\" trackScreenViews /> to your root layout, and page views are tracked. For custom events, call useOpenPanel().track('event_name', { properties }) in client components. The step-by-step guide is at /guides/nextjs-analytics."
},
{
"question": "Does OpenPanel support Next.js App Router?",
"answer": "Yes. The component works in the App Router and the Pages Router. Client-side navigation is tracked by the web SDK's history hooks, so no custom setup is needed."
},
{
"question": "Can I track events in Server Components and API Routes?",
"answer": "Yes. Create an OpenPanel instance from @openpanel/nextjs with your client id and client secret and call track() from Route Handlers, Server Actions or any server code. Server Components cannot use hooks, so use that instance there too, or the IdentifyComponent to identify a user from server data."
},
{
"question": "Does OpenPanel work with NextAuth.js or Clerk?",
"answer": "Yes. After authentication, call identify({ profileId: session.user.id, email }) on the client, or render <IdentifyComponent profileId={…} /> from the server. Any auth solution that gives you a stable user id works."
},
{
"question": "Does OpenPanel add significant bundle size to my Next.js app?",
"answer": "No. The client script is about 3 KB gzipped and loads async; GA4 is many times larger. The impact on your bundle and Core Web Vitals is negligible."
},
{
"question": "Can I self-host OpenPanel for my Next.js app?",
"answer": "Yes. OpenPanel is open source and self-hosts with Docker Compose and one install script. Point the SDK's apiUrl at your own server. Self-hosted has no event limits and is free to run."
}
]
},
"related_links": {
"guides": [
{
"title": "Next.js analytics setup",
"url": "/guides/nextjs-analytics"
},
{
"title": "React analytics setup",
"url": "/guides/react-analytics"
},
{
"title": "Track custom events",
"url": "/guides/track-custom-events"
}
],
"articles": [
{
"title": "Self-hosted web analytics",
"url": "/articles/self-hosted-web-analytics"
}
],
"comparisons": [
{
"title": "OpenPanel vs Google Analytics",
"url": "/compare/google-analytics-alternative"
},
{
"title": "OpenPanel vs PostHog",
"url": "/compare/posthog-alternative"
}
]
},
"ctas": {
"primary": {
"label": "Try OpenPanel Free",
"href": "https://dashboard.openpanel.dev/onboarding"
},
"secondary": {
"label": "View Source on GitHub",
"href": "https://github.com/Openpanel-dev/openpanel"
}
}
}