diff --git a/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/example.tsx b/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/example.tsx
new file mode 100644
index 00000000..c68ee8f3
--- /dev/null
+++ b/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/example.tsx
@@ -0,0 +1,99 @@
+import Image from 'next/image';
+import Link from 'next/link';
+
+export default function ExamplePage() {
+ return (
+
+ );
+}
diff --git a/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/index.tsx b/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/index.tsx
index 2aff5806..872c1038 100644
--- a/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/index.tsx
+++ b/e2e-tests/test-applications/nextjs-pages-router-test-app/src/pages/index.tsx
@@ -1,14 +1,15 @@
-import Image from "next/image";
-import { Geist, Geist_Mono } from "next/font/google";
+import Image from 'next/image';
+import { Geist, Geist_Mono } from 'next/font/google';
+import Link from 'next/link';
const geistSans = Geist({
- variable: "--font-geist-sans",
- subsets: ["latin"],
+ variable: '--font-geist-sans',
+ subsets: ['latin'],
});
const geistMono = Geist_Mono({
- variable: "--font-geist-mono",
- subsets: ["latin"],
+ variable: '--font-geist-mono',
+ subsets: ['latin'],
});
export default function Home() {
@@ -27,13 +28,8 @@ export default function Home() {
/>
diff --git a/src/nextjs/docs.ts b/src/nextjs/docs.ts
index 6f760c83..da12373b 100644
--- a/src/nextjs/docs.ts
+++ b/src/nextjs/docs.ts
@@ -31,8 +31,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: "/ingest",
ui_host: "${getUiHostFromHost(host)}",
- capture_pageview: 'history_change',
- capture_pageleave: true, // Enable pageleave capture
+ defaults: '2025-05-24',
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
debug: process.env.NODE_ENV === "development",
})
@@ -40,7 +39,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
return (
-
{children}
)
@@ -85,10 +83,10 @@ Example:
--------------------------------------------------
import { PostHog } from "posthog-node"
+// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
export default function PostHogClient() {
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
- capture_pageview: 'history_change',
flushAt: 1,
flushInterval: 0,
})
@@ -162,11 +160,8 @@ export default function App({ Component, pageProps }) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: "/ingest",
ui_host: "${getUiHostFromHost(host)}",
- capture_pageview: 'history_change',
+ defaults: '2025-05-24',
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
- loaded: (posthog) => {
- if (process.env.NODE_ENV === "development") posthog.debug()
- },
debug: process.env.NODE_ENV === "development",
})
}, [])
@@ -190,10 +185,10 @@ Example:
--------------------------------------------------
import { PostHog } from "posthog-node"
+// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
export default function PostHogClient() {
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
- capture_pageview: 'history_change',
flushAt: 1,
flushInterval: 0,
})
@@ -266,8 +261,7 @@ import posthog from "posthog-js"
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: "/ingest",
ui_host: "${getUiHostFromHost(host)}",
- capture_pageview: 'history_change',
- capture_pageleave: true, // Enable pageleave capture
+ defaults: '2025-05-24',
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
debug: process.env.NODE_ENV === "development",
});
diff --git a/src/react/docs.ts b/src/react/docs.ts
index 90544790..792c2bb6 100644
--- a/src/react/docs.ts
+++ b/src/react/docs.ts
@@ -41,6 +41,7 @@ root.render(
apiKey={${apiKeyText}}
options={{
api_host: ${hostText},
+ defaults: '2025-05-24',
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
debug: ${
envVarPrefix === 'VITE_PUBLIC_'