Websites your Next.js app serves
Visits go through your own app on each domain; nothing in the page points to an outside address. They are signed, so the stats count the real visitor and place, not your server.
Add the proxy route#
import { createProxy } from 'nahnu-analytics-sdk/next/server';
export const { GET, POST } = createProxy(); The folder name is yours; pass <Analytics base="/…"> if it isn’t /nq.
Add the component#
import { Analytics } from 'nahnu-analytics-sdk/next';
export default async function Layout({ children }) {
const tenant = await tenantForHost(); // your lookup by host name
return (
<html>
<body>
{children}
{tenant && <Analytics siteKey={tenant.siteKey} />}
</body>
</html>
);
} Page changes in the app are counted by themselves.
<Analytics> option | What it does |
|---|---|
exclude={['/admin*']} | Pages not to count |
props={{ plan: 'pro' }} | Added to every page view |
manual | Only views you send with view() count |
hash | #/routes count as pages |
localhost | Visits on localhost count too |
nonce | For a Content Security Policy |
The visitor’s address#
A visitor can send any header, so the proxy believes only the one your host sets. It detects Vercel (x-real-ip and its location headers), Netlify and Fly; anywhere else it takes the last address in X-Forwarded-For, added by your load balancer.
- Set
trust: 'cloudflare'when the app is only reachable through Cloudflare. - On a server with nothing in front, pass
ip: (req) => ….
Signing secrets#
The proxy asks the platform API for every site’s secret in one call and keeps them for an hour. A site key it doesn’t know (a new site) triggers one more call, at most once a minute; made-up keys are dropped without costing you requests.
To skip the call, keep site.install.proxy_secret in your database and pass secret: (siteKey) => ….
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!



