Next.js Native
Open-Source Analytics
100% server-side. No client JavaScript. No cookies. No GDPR banners. Just accurate analytics that respect your users.
Why Nextlytics?
Traditional analytics compromise privacy, slow down your site, and lose data. Nextlytics fixes all of that.
100% Server-Side
All tracking happens in Next.js middleware. No client JavaScript, no external calls. 100% accurate data, immune to ad blockers.
GDPR Compliant
No cookies, no fingerprinting, no personal data stored. Skip the cookie banners entirely.
Zero Overhead
No impact on page load. No additional network requests from browsers. Your site stays fast.
Backend-Agnostic
Send data to Posthog, Segment, Jitsu, or write directly to Postgres. Use what you already have.
Anonymous & Authenticated
Track both anonymous visitors and logged-in users. Integrates seamlessly with NextAuth.
Custom Events
Track form submissions, button clicks, and any custom event from your server components.
Multiple Backends
Posthog, Segment, Amplitude, or write directly to your database. Switch anytime.
Open Source
MIT licensed. No vendor lock-in, no hidden costs. Your data, your rules.
Add Analytics in 3 Steps
No complex setup. No dashboard configuration. Just a few lines of code.
npm install @nextlytics/core// src/nextlytics.ts
import { Nextlytics } from "@nextlytics/core/server";
import { segmentBackend } from "@nextlytics/core/backends/segment";
// Nextlytics runs in Edge middleware, so it can't import your main auth.ts
// if it pulls in Prisma, nodemailer, or other Node.js-only deps.
// Create a lightweight auth instance from your edge-safe base config.
// See: https://authjs.dev/guides/edge-compatibility
import NextAuth from "next-auth";
import authConfig from "./auth.config";
const { auth } = NextAuth(authConfig);
export const { middleware, analytics } = Nextlytics({
backends: [
segmentBackend({
writeKey: process.env.SEGMENT_WRITE_KEY!,
// For Jitsu: host: "https://ingest.g.jitsu.com"
}),
],
// Optional but recommended: identify authenticated users
callbacks: {
async getUser() {
const session = await auth();
if (!session?.user) return null;
return {
userId: session.user.id,
traits: { email: session.user.email, name: session.user.name },
};
},
},
});import { NextlyticsServer } from "@nextlytics/core/server";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<NextlyticsServer>{children}</NextlyticsServer>
</body>
</html>
);
}import { middleware } from "./nextlytics";
export { middleware };That's it. Every page view is now tracked server-side.
Ready to get accurate analytics?
Stop losing data. Stop asking for cookie consent. Start tracking with confidence.