// app/layout.tsx
import { DatabuddyProvider } from "@databuddy/sdk/react";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<DatabuddyProvider
clientId={process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID!}
/>
{children}
</body>
</html>
);
}Next.js analytics in one provider
Databuddy is cookieless analytics for Next.js: add the provider to your root layout and track pageviews, events, errors, and Web Vitals.
Pageviews and route changes, out of the box.
Visitors, sources, pages, and campaigns from the moment the provider loads.
- Google3,812
- Direct2,406
- chatgpt.com1,134
- news.ycombinator.com871
- x.com512
- /5,120
- /pricing2,214
- /docs/getting-started1,630
- /blog/launch942
- /compare/google-analytics518
Track outcomes on the server.
Send signup_completed from a Server Action so it counts even when the browser blocks scripts.
// app/signup/actions.ts
"use server";
import { Databuddy } from "@databuddy/sdk/node";
const analytics = new Databuddy({
apiKey: process.env.DATABUDDY_API_KEY!,
websiteId: process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID,
});
export async function signUp(formData: FormData) {
const user = await createAccount(formData);
await analytics.track({
name: "signup_completed",
eventId: `signup_completed:${user.id}`,
properties: { plan: "free" },
});
await analytics.flush();
}Keep visitors who use ad blockers.
Serve the script and send events from your own domain with two rewrites, then point the provider at them.
// next.config.ts
async rewrites() {
return [
{ source: "/_p/s.js", destination: "https://cdn.databuddy.cc/databuddy.js" },
{ source: "/_p/e/:path*", destination: "https://basket.databuddy.cc/:path*" },
];
}
// app/layout.tsx
<DatabuddyProvider
clientId={process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID!}
scriptUrl="/_p/s.js"
apiUrl="/_p/e"
/>Built for how Next.js apps ship
The same SDK covers the rest of what you'd otherwise add.
Errors with your source code
Turn on errors in the provider and upload source maps from CI to see your original file and line.
Web Vitals by route
LCP, INP, and CLS from real visitors, by page, browser, and country.
Feature flags in the same SDK
Wrap your app with the provider to read flags in Client Components, or evaluate them on the server.
Coming from PostHog
Swap the imports to @databuddy/sdk/posthog and your capture, identify, and flag calls keep working.
Databuddy vs Vercel Web Analytics, PostHog, and GA4
Pick the tool that fits how you work. Each comparison lists what the other tool does better.
Databuddy vs Vercel Analytics
Vercel Analytics starts at Free on Hobby
Pick Vercel Analytics if: Your sites run on Vercel and you want analytics inside your Vercel projects.
Pick Databuddy if: You host on more than one provider and want one dashboard for every site.
Databuddy vs PostHog
PostHog starts at Free plan
Pick PostHog if: You need in-app surveys.
Pick Databuddy if: You want one cookieless script for traffic, custom events, funnels, and goals.
Databuddy vs Google Analytics
Google Analytics starts at Free
Pick Google Analytics if: You run Google Ads and want GA4’s advertising integrations.
Pick Databuddy if: You want cookieless tracking by default, not only when a visitor denies consent.

Ask why signups dropped after a deploy.
Databunny reads your events, errors, and Web Vitals together and shows the query behind each answer.
Frequently asked questions
Have a question that isn't listed here? Email support@databuddy.cc.
Plan your setup and measurement
- Install and verify the tracker
Choose the integration for your stack, then confirm the events arriving in your dashboard.
- Choose a React or Next.js analytics SDK
Compare SDK integration, rendering, and event-tracking requirements for your application.
- Migrate PostHog SDK calls
Review compatible imports and the behavior that changes before replacing an existing integration.
