Diagnostics
LUM5006: Prerendered page that renders only in the browser
An spa page's prerender is true, set on the page or inherited from a layout, but its ssr is false.
Severity: error · Category: routing and server (5xxx)
Reported by: the route scanner (lumiose dev, lumiose check, lumiose build).
#What it means
The two options ask for opposite things. prerender = true renders the page's HTML at build time,
and the browser hydrates it. ssr = false renders the page only in the browser: the server sends
an empty shell and never loads the page's modules. The prerender = true can come from the page
itself or from the nearest layout that sets it. The ssr = false can come from the page itself,
from a layout above it, or from the project default lumiose({ ssr: false }).
When both are inherited, the error is reported once, on the deeper of the two layouts. When the
page sets ssr = false itself, it is reported on the page.
#Example
// src/routes/layout.stsx
export const mode = "spa";
export const ssr = false;// src/routes/page.stsx
export const prerender = true;
export default function Home() {
return <h1>Home</h1>;
}A browser-only page below a prerendering layout:
// src/routes/layout.stsx
export const mode = "spa";
export const prerender = true;// src/routes/editor/page.stsx
export const ssr = false;#How to fix it
- To prerender the page, let it render on the server: remove
export const ssr = false, or setexport const ssr = trueon the page. Then move browser-only code (window,document,AudioContext,localStorage) out of module scope and component setup, into event handlers oronMount(). - To keep the client-rendered shell, remove
export const prerender = true, or, when it comes from a layout, setexport const prerender = falseon the page (or on a layout between the two). A shell without params is already written to a static file bylumiose build.
lumiose({ prerender: true }) together with lumiose({ ssr: false }) is rejected by the plugin
for the same reason. With only lumiose({ prerender: true }), a page that sets ssr = false
stays a shell without this error.
#Related
- Rendering modes
- LUM5001: request API used during prerender.