Commit ae295da
authored
Nt 3090 nextjs csr (#262)
* init nextjs app
* scaffold Next.js reference implementation with monorepo conventions
Restructure the bare create-next-app scaffold into a proper monorepo
implementation with both React Web SDK and Node SDK dependencies,
PM2-managed mock/serve scripts, env config, and AGENTS.md aligned
with existing implementation patterns.
* feat: add client-side React SDK integration with OptimizationProvider
and client-resolved demo
* docs: comment OptimizationProvider mount to client to avoid SSR
localStorage crash
* refactor: use next/dynamic with ssr:false for client-only SDK provider
Replace the useState/useEffect mount guard with a dedicated
ClientProviderWrapper that uses next/dynamic({ ssr: false }). This is
the standard Next.js pattern for browser-only third-party SDKs and
keeps OptimizationProvider clean without SSR workarounds.
* feat: add server-resolved pattern and isolate route SDK boundaries
- Add Node SDK server singleton and Next.js middleware for cookie
lifecycle (ctfl-opt-aid profile management).
- Add server-resolved page: Server Component fetches entries and
resolves them via Node SDK, renders pure server HTML with zero
client JS for content.
- Add InteractiveControls as a small 'use client' component for
consent/identify on the server-resolved route.
- Isolate SDK setup per route: each route has its own layout with
its own ClientProviderWrapper, root layout is neutral.
- Remove custom OptimizationProvider wrapper; use SDK's
OptimizationRoot directly via dynamic import.
* docs: update README and AGENTS.md to reflect current architecture
Document isolated route layouts, server-resolved vs client-resolved
patterns, design decisions, cookie-based profile management, and the
singleton dev-mode recovery tip.
* docs: document singleton conflict, customer setup context, and future direction
Add context on why this reference implementation exists, the known
singleton conflict when navigating between routes, and plans to
gather customer architecture patterns from pre/post-sales to inform
which setups to prioritize.
* refactor: convert react-web-sdk_nextjs to CSR-only implementation
Remove server-resolved route, middleware, Node SDK dependency, and
all server-side resolution code. This implementation now uses only
@contentful/optimization-react-web for pure client-side entry
resolution. The SSR hybrid pattern lives in a separate
react-web-sdk+node-sdk_nextjs implementation.
* chore: remove spike-nextjs-support.md
Superseded by the actual reference implementations.
* chore: remove session notes file
* fix: exclude Next.js implementations from root ESLint
The root ESLint (v10) is incompatible with eslint-plugin-react pulled
by eslint-config-next. The Next.js implementations have their own
local eslint.config.mjs and are linted via their own setup.
* docs: update docs to match nextJs-ssr pattern
* chore: rename directory and project
* fix: ignore nextJs projects in the linting commands due to NextJs bug
* docs: fix format
* feat: implement Hybrid SSR + CSR Takeover pattern (Setup 2)
Convert from pure CSR to hybrid pattern: Server Component first paint
via Node SDK, Client Component interactive page via useOptimization().
Add middleware for cookie lifecycle, Node SDK singleton, and Link-based
SPA navigation between SSR and CSR routes.
* refactor: consolidate to single-page hybrid SSR+CSR takeover
* fix: format
* feat: prime Web SDK with server-resolved defaults on hydration
Pass server-resolved profile, selectedOptimizations, and changes into
OptimizationRoot via defaults prop. Eliminates the state gap between
SSR first paint and client takeover. Provider moved to page level to
receive server data as props.
* refactor: move SSR priming to stable app layout
Prime the layout-level OptimizationRoot from shared request-scoped
optimization data so SSR and CSR takeover use the same evaluated state.
This keeps the provider stable across navigations while preserving a
seamless first-paint handoff.
* docs: add nextJs implementation guide
* fix:format1 parent fc2d6f4 commit ae295da
28 files changed
Lines changed: 2026 additions & 2 deletions
File tree
- documentation/guides
- implementations/react-web-sdk+node-sdk_nextjs-ssr-csr
- app
- components
- config
- lib
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments