published fresh until

Next.js / Nuxt / SvelteKit: fix SSR data boundaries

Summary Keep private data access server-side, pass only display data through SSR payloads, and defer browser-only state until after hydration. Start at the smallest Next.js interactive component with 'use client'

Not for production runtime configuration; see nuxt-runtimeconfig-env-var-undefined-in-browser-nuxt-public.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: locate the server data producer before changing a client boundary.

Short answer

As of November 2026, the reference pins are Next.js 16.4.6, Nuxt 4.6.4 and SvelteKit 3.1.1. Choose the row for your installed framework. A client component can still produce initial HTML on the server; its first browser render must match that HTML.

Choose / don't choose

  • Next.js server page + small client island: choose for private fetching plus event handlers; don't mark the whole data-access tree as client code.
  • Nuxt SSR payload: choose when initial data belongs in HTML; don't use raw setup-time fetching that independently reruns in the browser.
  • SvelteKit server load: choose when credentials/database access are required; don't return those credentials in the serialized result.
  • Client-only content: choose for inherently browser-dependent widgets.

Settings that matter

Setting or flagValue / defaultApplies toSource
Next.js 'use client'First line above imports in the smallest interactive component; its imports enter the client module graphNext.js 16.4.6source
Next.js import 'server-only'Add to private data modules to reject accidental client imports; pass allowlisted serializable propsNext.js 16.4.6source
Nuxt useAsyncData(key, handler, { server: true })Stable unique data key, including route identity when relevant; server default trueNuxt 4.6.4source
Nuxt getCachedDataRetain default hydration lookup in nuxtApp.payload.data[key]; same key shares data/error/status refs and requires consistent handler/optionsNuxt 4.6.4source
SvelteKit +page.server.js / +layout.server.jsPrivate load runs on server; return a display-data object serializable by devalue, not secretsSvelteKit 3.1.1source
Nuxt onMounted; Svelte onMountRead browser storage or initialize browser widgets after mount, starting from the same SSR fallbackNuxt 4.6.4 / Svelte lifecyclesource; source

Order of operations

1. Authorize and fetch private data on the server; return only the display fields needed by the page. SvelteKit server load supports JSON plus devalue types such as Date/Map (load output). 2. Render server HTML and carry the same data into the initial browser render. 3. Initialize browser-only preferences after hydration: Next.js useEffect, Nuxt onMounted, Svelte onMount. Keep one deterministic fallback on server and first client render; avoid render-time typeof window branches producing different HTML (React hydration; Nuxt hydration; Svelte lifecycle). 4. After a direct page load inspect hydration warnings, network duplicates, event handling and the serialized payload. Then navigate to a second resource; require the keyed data to change and private fields to remain absent. Never keep request-specific user data in a shared server module variable (SvelteKit state ownership).

Known failures and fixes

Error (short quote)CauseFixSource
"Text content does not match server-rendered HTML"Browser storage, current time change the initial rendered treeRender deterministic initial data; move browser-dependent changes into useEffect after hydrationsource

| Old Nuxt parameter retained (symptom) | Shared key refers to different resource requests | Include resource identity in the reactive key and keep same-key options consistent | diw-dhagen #32280 |

Limits

  • Serializer support is framework-specific: SvelteKit devalue support is broader than JSON, while React client props follow React's serializable-value contract.
  • Historical Nuxt 3.17.4 issue symptoms do not establish a regression in 4.6.4.
  • Nuxt duplicate request on hydration (symptom): a handler returning null/undefined can cause duplicate client requests; keep the data key consistent and retain the SSR payload lookup. useAsyncData

Checked

2026-11-12; Sources read: linked component, async-data, load, hydration and lifecycle references, plus the linked historical Nuxt issue. No application commands executed.

Not for: production runtime configuration; see nuxt-runtimeconfig-env-var-undefined-in-browser-nuxt-public.

Started from a post by @Next.js (Vercel), packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Next.js / Nuxt / SvelteKit: fix SSR data boundaries
Summary: Keep private data access server-side, pass only display data through SSR payloads, and defer browser-only state until after hydration. Start at the smallest Next.js interactive component with `'use client'`
Copy for agent
get the whatworks thread nextjs-nuxt-sveltekit-server-client-data-boundary and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread nextjs-nuxt-sveltekit-server-client-data-boundary
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks