@posthog/next
0.11.1
Patch Changes
- #5407
6405dfdThanks @eli-r-ph! - Require posthog-node 5.58.0 or later, the first version with the span-context helpers they use. (2026-11-17) - Updated dependencies [
6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd]:- @posthog/core@1.69.0
- posthog-node@6.0.0
0.11.0
Minor Changes
- #5473
5c8f314Thanks @ablaszkiewicz! - feat:onRequestErrortakes identity from PostHog tracing headers before the cookie, drops a cookie session that posthog-js would have ended, and adds the request URL, method, path and user agent. NewwithPostHogProxycaptures errors thrown inproxy.tsor middleware without delaying the response. Errors that escape middleware or a proxy are marked unhandled. (2026-11-03)
Patch Changes
- Updated dependencies [
5c8f314]:- @posthog/core@1.63.0
0.10.0
Minor Changes
- #5315
e4df2d5Thanks @pauldambra! - Add an optional Node.js App Router span context bridge that reuses the configured PostHog client and request identity. (2026-10-28)
Patch Changes
0.9.0
Minor Changes
- #4656
39aa650Thanks @marandaneto! - Add opt-in$routetemplate capture for App Router and Pages Router pageviews. (2026-09-01)
Patch Changes
- Updated dependencies [
444bf35,aa72a36,6ae173f,6309cb2,6723395,ec550b8,6d6091e,0cddefe,cee2280,5874d1c,1406e04,e7f5733,5c6ab6f]:
0.8.6
Patch Changes
- #4578
bae46bfThanks @marandaneto! - Drop events when a before-send hook throws instead of sending the unmodified event. (2026-08-20) - Updated dependencies [
bae46bf,aef2f49]:
0.8.5
Patch Changes
- #4568
de7de16Thanks @dustinbyrne! - Fix request routing in the Next.js middleware proxy. (2026-08-19) - Updated dependencies [
3e0edff]:
0.8.4
Patch Changes
-
#4170
ba536baThanks @dustinbyrne! - Let Next.js dynamic rendering bailouts propagate when bootstrapping flags. (2026-07-16) -
#4169
faf3e7dThanks @dustinbyrne! - Require the Pages Router request context in server identity resolver types. (2026-07-16) -
Updated dependencies [
06d19a2]:- @posthog/core@1.43.1
- posthog-node@5.45.2
0.8.3
Patch Changes
- #4152
2578f08Thanks @dustinbyrne! - Remove the Pages RouterPostHogProvider.bootstrapprop; move its value toclientOptions.bootstrap. For App Router server-evaluated bootstrap, use fresh evaluated flags and payloads while preserving configured identity and session fields. (2026-07-16)
0.8.2
Patch Changes
- #4150
2e9405bThanks @dustinbyrne! - Fix Pages Router SSR feature flag hooks when Node loads the CommonJS posthog-js entrypoint. (2026-07-16)
0.8.1
Patch Changes
- #4093
4da3b41Thanks @dustinbyrne! - DedupegetDistinctIdresolution per request in the App Router: repeatedgetPostHog()calls within one request (e.g. across a layout and its pages) now share a single resolver invocation, keyed on the request'sheaders()instance. (2026-07-14)
0.8.0
Minor Changes
-
#4091
3336dbfThanks @dustinbyrne! - Replace thegetPostHogandgetServerSidePostHogexports with acreatePostHog()factory. Configure PostHog once in a shared module — including an optionalgetDistinctIdresolver that attributes server-side events and feature flags to the authenticated user — and use the returnedgetPostHogeverywhere.1import "server-only"; 2import { createPostHog } from "@posthog/next"; 3 4export const { getPostHog } = createPostHog();Pass
getDistinctIdto resolve identity from your auth session:1import "server-only"; 2import { createPostHog } from "@posthog/next"; 3import { auth } from "@/auth"; 4 5export const { getPostHog } = createPostHog({ 6 getDistinctId: async () => (await auth())?.user?.id, 7});In the Pages Router, import from
@posthog/next/pages; the returnedgetPostHog(ctx)requires theGetServerSidePropsContextand passes it to the resolver:1import { createPostHog } from "@posthog/next/pages"; 2 3export const { getPostHog } = createPostHog({ 4 getDistinctId: async (ctx) => 5 ctx 6 ? (await getServerSession(ctx.req, ctx.res, authOptions))?.user?.id 7 : undefined, 8});Call sites are unchanged apart from the import.
getPostHogis still async,ctxis still required in the Pages Router, and per-callapiKey/optionsmove intocreatePostHog():1// Before 2import { getPostHog } from "@posthog/next"; 3const posthog = await getPostHog(apiKey, { host }); 4 5// After 6import { getPostHog } from "@/lib/posthog"; 7const posthog = await getPostHog();In the Pages Router,
getServerSidePostHog(ctx)becomesgetPostHog(ctx). (2026-07-09)
Patch Changes
- #4091
3336dbfThanks @dustinbyrne! - Fix Pages Router server clients to apply request context after async initialization: the Pages Router path ofcreatePostHog().getPostHog(ctx)now wraps method calls inwithContextinstead of callingenterContext, which does not propagate back to the caller across the helper's await boundary. (2026-07-09) - Updated dependencies [
e6b5ab2,d0e531a]:- @posthog/core@1.40.1
0.7.2
Patch Changes
- #4092
335dd05Thanks @dustinbyrne! - Fix@posthog/next/pagesin Pages Router server bundles so server APIs likegetServerSidePropsresolve correctly instead of importing the client entrypoint. (2026-07-08)
0.7.1
Patch Changes
- #4055
64e04baThanks @marandaneto! - Retry/flagsrequests that receive HTTP 502 or 504 responses across SDKs that use the shared core flags client. (2026-07-02) - Updated dependencies [
64e04ba]:- @posthog/core@1.39.4
- posthog-node@5.39.3
0.7.0
Minor Changes
- #3941
e76e878Thanks @dustinbyrne! - Enable same-origin client-side tracing headers by default (2026-06-24)
0.6.0
Minor Changes
- #3925
1b0191cThanks @dustinbyrne! - Enable exception capture by default.- Client-side PostHog initialization now sets
capture_exceptions: trueby default. PassclientOptions.capture_exceptionsto override this. - Apps can export
onRequestErrorfrom@posthog/nextininstrumentation.tsto capture server-side request errors handled by Next.js, including in the Edge runtime. - Alternatively, import
captureRequestErrorand call it fromonRequestError. (2026-06-23)
- Client-side PostHog initialization now sets
Patch Changes
- Updated dependencies [
6391106]:
0.5.0
Minor Changes
-
#3921
c28b161Thanks @marandaneto! - Adddisable_capture_url_hashesto strip URL fragments from automatically captured URLs. It is disabled by default for backwards compatibility, and enabled automatically whenconfig.defaultsis'2026-06-25'or later. Enabling it (either explicitly or via the'2026-06-25'defaults) is a breaking behavior change for SPAs that rely on URL hashes for routing or analytics, because hash-based routes will be collapsed to the same URL without the fragment in fields such as$current_url,$initial_current_url,$session_entry_url, autocapture$elements[*].attr__href,$external_click_url, replayhrefURLs, heatmaps, web vitals$current_url, logsurl.full, conversationscurrent_url/request_url, or Next.js Pages Router$pageview$current_url.If you only want to capture some hashes, leave hash capture enabled and use
before_sendto remove or redact sensitive hash values before events are sent. (2026-06-23)
Patch Changes
- Updated dependencies [
c28b161]:- posthog-js@1.393.0
- @posthog/core@1.36.0
0.4.97
Patch Changes
- #3886
e6d7fe2Thanks @marandaneto! - Stop sending deprecated no-op top-leveltype,library, andlibrary_versionfields in event batch payloads. Useproperties.$libandproperties.$lib_versionfor SDK metadata; legacy queuedlibraryandlibrary_versionvalues are used as fallbacks when the official$properties are missing. (2026-06-18) - Updated dependencies [
e6d7fe2]:- @posthog/core@1.35.2
- posthog-node@5.38.1
0.4.96
Patch Changes
- #3837
29bf8e3Thanks @marandaneto! - Add missing bugs metadata to package manifests. (2026-06-15) - Updated dependencies [
29bf8e3,d3a9462]:- posthog-js@1.386.7
- @posthog/core@1.32.4
- posthog-node@5.37.1
- @posthog/react@1.10.2
0.4.95
Patch Changes
0.4.94
Patch Changes
- Updated dependencies [
25822ac]:
0.4.93
Patch Changes
0.4.92
Patch Changes
- Updated dependencies [
612f97a]:
0.4.91
Patch Changes
0.4.90
Patch Changes
- Updated dependencies [
2d21ada]:
0.4.89
Patch Changes
- Updated dependencies [
d9462b3]:
0.4.88
Patch Changes
- Updated dependencies [
0e22d77]:
0.4.87
Patch Changes
- Updated dependencies [
0c2acb9]:
0.4.86
Patch Changes
- Updated dependencies [
783ba46]:
0.4.85
Patch Changes
- Updated dependencies [
7820929]:- posthog-js@1.383.2
- posthog-node@5.36.7
- @posthog/react@1.10.1
- @posthog/core@1.30.13
0.4.84
Patch Changes
- Updated dependencies [
e481b0c]:
0.4.83
Patch Changes
0.4.82
Patch Changes
- Updated dependencies [
9877710]:
0.4.81
Patch Changes
- Updated dependencies [
a7bd828]:
0.4.80
Patch Changes
- Updated dependencies [
ced0039]:
0.4.79
Patch Changes
0.4.78
Patch Changes
- Updated dependencies [
9287c87]:
0.4.77
Patch Changes
- Updated dependencies [
32de5d2]:
0.4.76
Patch Changes
- Updated dependencies [
374962a]:
0.4.75
Patch Changes
0.4.74
Patch Changes
- Updated dependencies [
c487070]:
0.4.73
Patch Changes
- Updated dependencies [
3aff16e]:- @posthog/react@1.10.0
0.4.72
Patch Changes
- Updated dependencies [
8fcf40d]:
0.4.71
Patch Changes
- Updated dependencies [
8181354]:
0.4.70
Patch Changes
0.4.69
Patch Changes
- Updated dependencies [
663e250]:
0.4.68
Patch Changes
0.4.67
Patch Changes
0.4.66
Patch Changes
- Updated dependencies [
9cac1f6]:
0.4.65
Patch Changes
- Updated dependencies [
cafa9cc]:
0.4.64
Patch Changes
- Updated dependencies [
5568f12]:
0.4.63
Patch Changes
- Updated dependencies [
5d7a2d3]:
0.4.62
Patch Changes
0.4.61
Patch Changes
0.4.60
Patch Changes
- Updated dependencies [
f42f371]:
0.4.59
Patch Changes
- #3646
4f87827Thanks @marandaneto! - Avoid throwing or initializing PostHogProvider when no API key or client is provided (2026-05-21) - Updated dependencies [
87e2145,4f87827,280832b]:- posthog-js@1.374.4
- @posthog/react@1.9.1
- @posthog/core@1.29.7
- posthog-node@5.34.9
0.4.58
Patch Changes
- Updated dependencies [
12ef3f6]:
0.4.57
Patch Changes
0.4.56
Patch Changes
- Updated dependencies [
e119eec]:
0.4.55
Patch Changes
- Updated dependencies [
df91995]:
0.4.54
Patch Changes
- Updated dependencies [
07a0f5f]:
0.4.53
Patch Changes
0.4.52
Patch Changes
- Updated dependencies [
221973e]:
0.4.51
Patch Changes
- #3549
77ee9dfThanks @brandonhines-mialabs! - Fix@posthog/next/pagesdefault export condition to resolve to the client barrel (pages.client.js) instead of the server barrel (pages.js), matching the behavior of the root"."export. This prevents bundlers that don't match a more specific condition from pulling inserver-onlyandposthog-nodeunnecessarily. (2026-05-14)
0.4.50
Patch Changes
- #3608
afb0ae8Thanks @marandaneto! - Fix Next.js pageview tracking to send absolute current URLs (2026-05-13)
0.4.49
Patch Changes
- Updated dependencies [
4b895bf]:
0.4.48
Patch Changes
- #3599
ad60818Thanks @turnipdabeets! - Expose UUID and cookie helpers from@posthog/coreandposthog-nodefor users managing distinct_id outside the browser SDK (e.g. Lambda functions handing out cross-domain redirects). The helpers were already implemented in@posthog/next— this change lifts them to core so all SDKs can re-use them.@posthog/nextnow re-exports the same surface from@posthog/coreto keep existing consumers working without churn. Closes #2143. (2026-05-12) - Updated dependencies [
ad60818]:
0.4.47
Patch Changes
- Updated dependencies [
223d925]:
0.4.46
Patch Changes
- Updated dependencies [
7d027bc]:
0.4.45
Patch Changes
0.4.44
Patch Changes
0.4.43
Patch Changes
- #3543
ece3097Thanks @dustinbyrne! - Publish@posthog/nextfrom the release workflow so npm catches up with the versions already recorded in the changelog. (2026-05-07)
0.4.42
Patch Changes
-
#3533
eb546b4Thanks @brandonhines-mialabs! - Fix@posthog/next/pagespackaging so the documented Pages Router setup builds without aserver-onlyimport error.The
./pagessubpath previously had no per-runtimeexportsconditions, so any module importing from@posthog/next/pages(e.g.pages/_app.tsx) transitively pulled in'server-only'andposthog-node. Next.js rejects'server-only'from client modules before tree-shaking can drop the unused re-exports, breakingnext build. The barrel is now split per runtime:browser→./dist/pages.client.js—PostHogProvider,PostHogPageViewedge-light/edge/worker→./dist/pages.edge.js—postHogMiddleware,PostHogPageView,DEFAULT_INGEST_PATHreact-server/default→./dist/pages.js— full surface includinggetServerSidePostHogandgetPostHog
Existing imports (
from '@posthog/next/pages') keep working unchanged; the resolver picks the right barrel per runtime. (2026-05-06)
0.4.41
Patch Changes
- Updated dependencies [
026e09d]:
0.4.40
Patch Changes
0.4.39
Patch Changes
- Updated dependencies [
8aee3d5]:
0.4.38
Patch Changes
- Updated dependencies [
f8bc02f]:
0.4.37
Patch Changes
0.4.36
Patch Changes
- Updated dependencies [
70ba8f8]:
0.4.35
Patch Changes
- Updated dependencies [
974e4b2]:
0.4.34
Patch Changes
- Updated dependencies [
c726aae]:
0.4.33
Patch Changes
- Updated dependencies [
5a6b2a5]:
0.4.32
Patch Changes
- Updated dependencies [
5b8efc3]:
0.4.31
Patch Changes
- Updated dependencies [
cba2570]:
0.4.30
Patch Changes
- Updated dependencies [
70508df]:
0.4.29
Patch Changes
- Updated dependencies [
eaa1322]:
0.4.28
Patch Changes
- Updated dependencies [
3c4fc1e]:
0.4.27
Patch Changes
- #3428
afc7655Thanks @dustinbyrne! - Fix native ESM module resolution in@posthog/nextso it can be imported from Vitest and other Node ESM environments. (2026-04-24) - Updated dependencies [
61cf83e,daf028d]:
0.4.26
Patch Changes
- Updated dependencies [
eadbcd7]:
0.4.25
Patch Changes
- Updated dependencies [
96f19b7]:
0.4.24
Patch Changes
- Updated dependencies [
2da17e8]:
0.4.23
Patch Changes
- Updated dependencies [
1a8b727]:
0.4.22
Patch Changes
- Updated dependencies [
6f19ce8]:
0.4.21
Patch Changes
- Updated dependencies [
922a1c1]:
0.4.20
Patch Changes
- Updated dependencies [
b26c57c]:
0.4.19
Patch Changes
- #3426
1a0b58dThanks @marandaneto! - Trim surrounding whitespace from user-provided API keys, personal API keys, and host config values before using them. (2026-04-21) - Updated dependencies [
1a0b58d]:
0.4.18
Patch Changes
- Updated dependencies [
d61bce1]:
0.4.17
Patch Changes
0.4.16
Patch Changes
- Updated dependencies [
4a65604]:
0.4.15
Patch Changes
0.4.14
Patch Changes
- #3376
e8548a5Thanks @dustinbyrne! - fix: pass bootstrap flags via React context so feature flag hooks return correct values during SSR (2026-04-15)
0.4.13
Patch Changes
0.4.12
Patch Changes
- Updated dependencies [
f1bea33]:
0.4.11
Patch Changes
- Updated dependencies [
d7c71b1]:
0.4.10
Patch Changes
0.4.9
Patch Changes
- Updated dependencies [
353be9a]:
0.4.8
Patch Changes
- Updated dependencies [
575e354]:
0.4.7
Patch Changes
- Updated dependencies [
802bf39]:
0.4.6
Patch Changes
- Updated dependencies [
b599672]:
0.4.5
Patch Changes
- Updated dependencies [
c735b08]:
0.4.4
Patch Changes
- Updated dependencies [
3939856]:
0.4.3
Patch Changes
- Updated dependencies [
dbdddca]:
0.4.2
Patch Changes
- Updated dependencies [
c387f6d]:
0.4.1
Patch Changes
- Updated dependencies [
57ee5b2]:
0.4.0
Minor Changes
- #3302
fc5589fThanks @dmarticus! - preserve $set_once semantics in local flag evaluation cache (2026-04-07)
Patch Changes
- Updated dependencies [
fc5589f]:
0.3.1
Patch Changes
- Updated dependencies [
b25b689]:
0.3.0
Minor Changes
- #3301
bd4b0acThanks @dustinbyrne! - Read PostHog tracing headers (X-POSTHOG-SESSION-ID, X-POSTHOG-DISTINCT-ID, X-POSTHOG-WINDOW-ID) in getPostHog() and getServerSidePostHog() (2026-04-02)
Patch Changes
0.2.19
Patch Changes
- #3309
197eedaThanks @marandaneto! - Extract CLI and sourcemap utilities from @posthog/core into @posthog/plugin-utils to remove cross-spawn from React Native dependencies (2026-04-01) - Updated dependencies [
197eeda,c5feb5c,7b944fc]:
0.2.18
Patch Changes
- Updated dependencies [
2365df5]:
0.2.17
Patch Changes
- Updated dependencies [
bab5f3a]:
0.2.16
Patch Changes
0.2.15
Patch Changes
- Updated dependencies [
4bdfdbc]:
0.2.14
Patch Changes
0.2.13
Patch Changes
- Updated dependencies [
32edaad]:
0.2.12
Patch Changes
- Updated dependencies [
5784dca]:
0.2.11
Patch Changes
0.2.10
Patch Changes
- Updated dependencies [
664a11b]:
0.2.9
Patch Changes
- Updated dependencies [
42fbd41]:
0.2.8
Patch Changes
0.2.7
Patch Changes
- Updated dependencies [
314120a]:
0.2.6
Patch Changes
0.2.5
Patch Changes
0.2.4
Patch Changes
- Updated dependencies [
c265d62]:
0.2.3
Patch Changes
0.2.2
Patch Changes
0.2.1
Patch Changes
- Updated dependencies [
4009c15]:
0.2.0
Minor Changes
-
#3215
429b389Thanks @dustinbyrne! - feat: renameoptOutByDefaulttoseedAnonymousCookieRenamed to better express what the option does: to control whether the middleware seeds a cookie containing an anonymous identifier on first page load.
Migration: replace
optOutByDefault: truewithseedAnonymousCookie: false. (2026-03-10)
0.1.1
Patch Changes
0.1.0
Minor Changes
- #3122
706adb8Thanks @dustinbyrne! - Initial release of @posthog/next, a PostHog integration with Next.js (2026-03-06)
Patch Changes
- Updated dependencies [
2b0cd52]: