- Add dedicatedPage flag to integration registry (25 true, 50 false) - Delete hardcoded nextjs/react/vue/wordpress route pages (wrong metadata) - Hub page routes non-dedicated integrations to /integrations/script-tag - Add 301 redirects for 50 removed slugs → /integrations/script-tag - Migrate guide content from TSX to MDX (content/integrations/*.mdx) - Add gray-matter, next-mdx-remote, remark-gfm dependencies - Add content loader (lib/integration-content.ts) matching ciphera-website pattern - Add prebuild script for integration guide index generation - Sitemap reduced from 83 to 35 URLs with real lastmod dates - Remove seoDescription from registry (now in MDX frontmatter)
69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
---
|
|
title: "Next.js"
|
|
description: "Step-by-step guide to adding Pulse privacy-first analytics to your Next.js app with next/script. Covers App Router and Pages Router."
|
|
category: "framework"
|
|
brandColor: "#000000"
|
|
officialUrl: "https://nextjs.org/docs"
|
|
relatedIds: ["react", "vercel", "nuxt"]
|
|
date: "2026-03-28"
|
|
---
|
|
|
|
The best way to add Pulse to your Next.js application is using the built-in `next/script` component.
|
|
|
|
---
|
|
|
|
## Method 1: App Router
|
|
|
|
Add the Pulse script to your root layout so it loads on every page.
|
|
|
|
<CodeBlock filename="app/layout.tsx">{`import Script from 'next/script'
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<html lang="en">
|
|
<head>
|
|
<Script
|
|
defer
|
|
src="https://pulse.ciphera.net/script.js"
|
|
data-domain="your-site.com"
|
|
strategy="afterInteractive"
|
|
/>
|
|
</head>
|
|
<body>{children}</body>
|
|
</html>
|
|
)
|
|
}`}</CodeBlock>
|
|
|
|
## Method 2: Pages Router
|
|
|
|
If you're using the Pages Router, add the script to your custom `_app.tsx`.
|
|
|
|
<CodeBlock filename="pages/_app.tsx">{`import Script from 'next/script'
|
|
import type { AppProps } from 'next/app'
|
|
|
|
export default function App({ Component, pageProps }: AppProps) {
|
|
return (
|
|
<>
|
|
<Script
|
|
defer
|
|
src="https://pulse.ciphera.net/script.js"
|
|
data-domain="your-site.com"
|
|
strategy="afterInteractive"
|
|
/>
|
|
<Component {...pageProps} />
|
|
</>
|
|
)
|
|
}`}</CodeBlock>
|
|
|
|
## Configuration options
|
|
|
|
- `data-domain` — your site's domain (without `https://`)
|
|
- `src` — the Pulse script URL
|
|
- `strategy="afterInteractive"` — loads the script after the page becomes interactive
|
|
|
|
For more details, see the [Next.js Script docs](https://nextjs.org/docs/app/api-reference/components/script).
|