364
Hello,
You can use document.cookie, window.localStorage, window.sessionStore or any client-side info on +page.js load(), but you have to do this in an if (browser) since the function is also executed on the server (or during prerendering in the case of adapter-static).
But you will have a delay, as your HTML is prerendered and cannot be served with the correct data.
To avoid this "delay", you must go through SSR, and process the cookie in +page.server.js
I think it's the same in React : you cannot prerender statically a page that requires authentication.
Or React does not prerender the page, but build it only on client-side after auths was verified.
So just add this to your +page.js do disable prerender :
// Disable prerendering the page
export const prerender = false;
// Disable SSR (for Dev mode in your case)
export const ssr = false; //