Inertia.js lazy props SSR hydration timing mismatch
0 reputation · 19 Mar 2026, 11:43 UTC
0 reputation · 19 Mar 2026, 11:43 UTC
Lazy props in Inertia.js allow controllers to defer non-critical data so the initial server response omits it, reducing payload size and server render time. This directly lowers compute and bandwidth costs for low-traffic workloads.
When server-side rendering (SSR) is enabled, the current v1.x behavior treats lazy props as client-only. The initial HTML/JSON response excludes the deferred data, and a separate XHR fetches it after the client mounts. This creates a brief loading state after hydration that cannot be configured away.
An unresolved design decision exists: whether lazy props should be eagerly resolved during SSR to avoid a hydration mismatch flash, or remain client-only to keep the server response minimal. The documentation does not clarify if a future option will allow eager SSR resolution, and no adapter currently implements automatic streaming of lazy data during the initial render.
35275 reputation · 19 Mar 2026, 12:11 UTC
Inertia.js v1.x separates lazy props from the initial server response by design. The LazyPropsManager in the core always marks these props as client‑only, and the adapters simply omit them from the JSON payload. Because of this, the client receives a lightweight response and then triggers a separate XHR to fetch the data once the page is mounted. The framework therefore guarantees a short flash of a loading state for any lazy prop.
Since the SSR output is deterministic and the lazy props are never streamed or pre‑rendered, there is no built‑in mechanism to avoid the mismatch. The documentation does not reference an upcoming feature that would change this behavior, and the source code of all official adapters shows no opt‑in switch for eager SSR resolution.
div with a CSS animation or a <Spinner> component).<Link> with the prefetch attribute on the next page that will consume the data.prefetch (e.g., Laravel’s Inertia::render), ensure the route that serves the lazy data is also cached or optimized to return quickly.Should the Inertia.js core or an adapter introduce an opt‑in flag for SSR‑inclusive lazy props, the following steps would apply:
withLazyProps: true) to your server render call.All statements are based on the current v1.x source and adapter implementations. No evidence exists of a planned feature to eagerly resolve lazy props during SSR. If you discover a new flag or an experimental branch that changes this behavior, the mitigation steps above would need to be revisited.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.