Skill 09 · Contentful Personalization
Subchapter 9.15
references/optimization-overview.mdMarkdown5 KBView on GitHub
Use this reference for the recommended @contentful/optimization-* family. Keep legacy maintenance
decisions in sdk-selection.md; this file describes the current runtime surfaces.
| Project runtime | Package | Load next |
|---|---|---|
| React SPA or React browser app | @contentful/optimization-react-web | optimization-react-web.md |
| Next.js App Router | @contentful/optimization-nextjs | optimization-nextjs-app-router.md |
| Next.js Pages Router | @contentful/optimization-nextjs | optimization-nextjs-pages-router.md |
| Browser app without React | @contentful/optimization-web | optimization-web.md |
| Node.js server or server function | @contentful/optimization-node | optimization-node.md |
| React Native | @contentful/optimization-react-native | optimization-react-native.md |
Always load optimization-shared.md with the selected runtime file.
Do not wire lower layers directly when an application-facing package exists:
@contentful/optimization-core, API client, and API schemas are lower-level building blocks, not
the normal starting point for application code.@contentful/optimization-web-preview-panel.Native iOS and Android SDKs exist upstream, but this reference pack deliberately excludes them until they have the same verified knowledge-base and blueprint coverage as the runtimes above.
Prefer repository evidence over the user’s shorthand:
app/, Server Components, route handlers, or proxy.ts indicate Next.js App Router.pages/, _app.tsx, or getServerSideProps indicate Next.js Pages Router.react-router or @tanstack/react-router without Next.js indicates React Web.react-native plus native platform directories or Metro indicates React Native.If both Next.js routers are present, determine which tree owns the personalized route. Do not mix router-specific factories or bound components.
createNextjsAppRouterOptimization from
@contentful/optimization-nextjs/app-router.createNextjsPagesRouterOptimization from
@contentful/optimization-nextjs/pages-router.@contentful/optimization-nextjs/pages-router/server.@contentful/optimization-nextjs/client.setConsent, flushEvents, identifyUser, trackPageView, resetUser,
trackScreen, and trackEvent.forRequest(), not on the process singleton.Read installed package versions from the target project and verify its lockfile before giving exact
upgrade commands. Keep related @contentful/optimization-* packages compatible; do not copy a
version from this reference into a project blindly. React Native may use a different prerelease
cadence from the Web, React, Next.js, and Node packages.
For a new integration:
Do not mechanically rename legacy @ninetailed/* imports. Provider lifecycle, consent, identity,
entry rendering, router integration, and server state ownership differ. First classify the current
architecture, then replace one lifecycle boundary at a time using the selected runtime reference.