svelte icon indicating copy to clipboard operation
svelte copied to clipboard

364

Open ghost opened this issue 2 years ago • 2 comments

ghost avatar Dec 16 '23 20:12 ghost

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

adiguba avatar Dec 16 '23 21:12 adiguba

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; // 

adiguba avatar Dec 16 '23 21:12 adiguba