Cookieless analytics for Next.js in 2 minutes
Add privacy-first product analytics to a Next.js App Router project: install, init once, track what matters.
By NightOwl · Updated · 1 min read
Set it up in three steps#
- 1
Install
Terminal npm i @shipabase/js.env.local NEXT_PUBLIC_SHIPABASE_KEY=SB-EU-xxxxxxxxxx - 2
Call init once, on the client
app/providers.tsx "use client"; import { useEffect } from "react";import { init } from "@shipabase/js"; export function Providers({ children }: { children: React.ReactNode }) { useEffect(() => { init(process.env.NEXT_PUBLIC_SHIPABASE_KEY!); }, []); return <>{children}</>;}Wrap
{children}inapp/layout.tsxwith<Providers>. Never callinitin a Server Component. - 3
Track what matters
any client component import { trackEvent } from "@shipabase/js"; trackEvent("project_created", { plan: "pro" });- Name events in
snake_case,object_verb, past tense:signup_completed,invoice_sent. - 5 to 15 events is typical. Track actions, not every click.
- Keep props anonymous: plan, count, variant. Never emails or user IDs.
- Name events in
For the Pages Router and the full reference, see the Next.js setup guide.
Why no cookie banner?#
The SDK stores nothing in the browser: no cookies, no localStorage. Visitors are counted with an anonymous hash that changes every day. See how visitors are counted for the details.
FAQ
Does it work with the Pages Router?
Yes. Call init in a useEffect in pages/_app.tsx.
Are page views tracked automatically?
Yes, since @shipabase/js 0.4, including client-side route changes in the App Router.


