Replies: 3 comments
-
That depends on what you're exporting from your hooks file. So far, the only export for client hooks is to handle errors. Exporting handle from your client hook will have no effect. |
Beta Was this translation helpful? Give feedback.
-
hooks.client.ts looks to run every +layout.svelte change. (sveltekit 2) |
Beta Was this translation helpful? Give feedback.
-
hooks.client.ts runs initially when the client gets loaded and before the client actually takes over rendering (before hydration). The reason this file exists is because of client hooks like handleError and I suggest you only use it for that. It never runs on the server, only on the client for the initial load. |
Beta Was this translation helpful? Give feedback.
-
So I understand that hooks.server.ts runs on every request but when i use hooks.client.ts, it only runs once when I refresh the page. If someone could explain when I would use this file, that would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions