Skip to content

fix(content): version-gate the Next.js client init rule#236

Closed
gewenyu99 wants to merge 1 commit into
mainfrom
posthog-code/nextjs-version-gate-report-wrapper
Closed

fix(content): version-gate the Next.js client init rule#236
gewenyu99 wants to merge 1 commit into
mainfrom
posthog-code/nextjs-version-gate-report-wrapper

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Why

instrumentation-client.ts only runs on Next.js 15.3+. On older versions it is silently ignored, so an agent following our guidance leaves client-side PostHog uninitialized (seen in a benchmark run against a Next.js 14.2.5 app). The existing nextjs commandment recommended instrumentation-client.ts with no version check and no alternative.

What

One line in context/commandments.yaml — the nextjs init commandment now says which init location to use for which version:

Initialize client-side PostHog in exactly one place, based on the "next" version in package.json: on 15.3 and later, use instrumentation-client.ts; below 15.3, use a "use client" PostHogProvider in the root layout (or _app), because instrumentation-client.ts is ignored there

Commandments fold into every skill tagged nextjs at build time, so this reaches all Next.js skills without touching them individually.

Verification

  • npm test — 107/107 pass
  • npm run build — clean; the new rule appears in every built Next.js SKILL.md under dist/marketplace

Created with PostHog Code

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@gewenyu99
gewenyu99 force-pushed the posthog-code/nextjs-version-gate-report-wrapper branch from 9e7403e to 045e424 Compare July 14, 2026 18:05
@gewenyu99 gewenyu99 changed the title fix(content): gate Next.js client init on 15.3 and disambiguate the wizard-report wrapper fix(content): gate Next.js client init guidance on the 15.3 cutoff Jul 14, 2026
instrumentation-client.ts is ignored on Next.js below 15.3, so client-side
PostHog silently never initializes there. The nextjs commandment now states
which init location to use for which version.

Generated-By: PostHog Code
Task-Id: f3b2162f-9a47-4d22-a83e-0a66900ed730
@gewenyu99
gewenyu99 force-pushed the posthog-code/nextjs-version-gate-report-wrapper branch from 045e424 to 4628353 Compare July 14, 2026 18:08
@gewenyu99 gewenyu99 changed the title fix(content): gate Next.js client init guidance on the 15.3 cutoff fix(content): version-gate the Next.js client init rule Jul 14, 2026
@gewenyu99 gewenyu99 closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant