Integrations · Apps

Next.js, under your own brand.

Track every custom domain your Next.js app serves with a proxy route and the Analytics component. Visits go through your own app on each domain, signed, so the stats count the real visitor and place.

First-partySigned visitsPage changes counted
app/nq/[file]/route.tsTS
import { createProxy } from 'nahnu-analytics-sdk/next/server';
export const { GET, POST } = createProxy();

Illustration

At a glance

White-label tracking on every domain.

What changes when your Next.js app uses the SDK.

  • Through your own app

    Nothing in the page points to an outside address.

  • Signed visits

    The stats count the real visitor and place, not your server.

  • Page changes counted

    Moves within the app count by themselves.

  • One site per tenant

    Pass each tenant’s site key to the component.

The component

Options for <Analytics>.

Set on the component in your layout.

OptionExampleWhat it does
excludeexclude={['/admin*']}Pages not to count
propsprops={{ plan: 'pro' }}Added to every page view
manualmanualOnly views you send with view() count
hashhash#/routes count as pages
localhostlocalhostVisits on localhost count too
noncenonceFor a Content Security Policy

Where it shows

Where you see it.

Each tenant domain is a website in Nahnu Analytics.

  • Each tenant’s dashboard

    Visitors, pages and sources per domain.

  • Events and goals

    track() events become goals when you add one.

  • Signed-in users

    identify() makes one person across devices and domains.

  • Funnels

    Across your events and pages.

  • Revenue

    Upgrades and purchases with an amount.

  • Linked sites

    Follow visitors from your marketing site into the app.

Events and users

track() and identify() from any client component.

Record what people do in the app and who they are once they sign in. An event becomes a goal when you add one with its name.

  • identify(user.id) after sign-up or sign-in
  • Revenue on any event, such as an upgrade
  • Funnels work across these events and pages
Your own web app →
Any client componentTS
import { track, identify } from 'nahnu-analytics-sdk/next';

identify(user.id);
track('Project created', { props: { template: 'shop' } });
track('Upgraded', { revenue: { amount: 49, currency: 'USD' } });

The visitor’s address

Only the header your host sets is believed.

A visitor can send any header, so the proxy believes only the one your host sets. It detects Vercel, Netlify and Fly; anywhere else it takes the last address in X-Forwarded-For.

  • Set trust to cloudflare when the app is only reachable through Cloudflare
  • On a server with nothing in front, pass ip: (req) => …
  • Signing secrets are fetched in one call and kept for an hour
Read the Next.js guide →
Detected hostsProxy
  • Vercelx-real-ip
  • NetlifyDetected
  • FlyDetected
  • Anywhere elseX-Forwarded-For

Questions

Next.js questions

Something else? Ask us.

Does the page call an outside address?

No. Visits go through your own app on each domain.

Are page changes in the app counted?

Yes, by themselves. Use manual to send only the views you choose.

Can I use another folder than /nq?

Yes. The folder name is yours; pass base to the Analytics component.

How are signing secrets fetched?

The proxy asks for every site’s secret in one call and keeps them for an hour. Or pass secret to skip the call.

Try it on every client site.

Unlimited websites, every feature, one license.