get hooks.server.ts to run on pre-rendered pages #7551
-
I have an app where users can login and like posts but when the user goes onto a page that is pre-rendered the hooks.server.ts doesn't run which means the user isn't logged in and shows them as logged out. is there a way to fix this by running hooks.server.ts on every page including pre rendered pages? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Prerendered pages compute the page contents (runnning load functions) at build time, so you have to fetch the user data client-side after the page is mounted. If you want to fetch data before the page is mounted (load functions), you should not prerender the page. More info here: https://kit.svelte.dev/docs/page-options#prerender-when-not-to-prerender
|
Beta Was this translation helpful? Give feedback.
Prerendered pages compute the page contents (runnning load functions) at build time, so you have to fetch the user data client-side after the page is mounted.
If you want to fetch data before the page is mounted (load functions), you should not prerender the page.
More info here: https://kit.svelte.dev/docs/page-options#prerender-when-not-to-prerender