typesafe-i18n-demo-sveltekit
typesafe-i18n-demo-sveltekit copied to clipboard
Hooks.server.js and Layout.server.js runs multiple times
Hooks.server.js and Layout.server.js runs multiple times instead of once. How can I solve it?
I use the latest version of Sveltekit and typesafe-i18n.
As far as I know hooks.ts
will run on each request.
Regarding +layout.server.ts
, please take a look at the official SvelteKit docs: https://kit.svelte.dev/docs/load#invalidation.
I would assume you can prevent this by removing those lines: https://github.com/ivanhofer/typesafe-i18n-demo-sveltekit/blob/main/src/routes/%2Blayout.ts#L12-L14
Maybe you can also prevent this with the depends
function: https://kit.svelte.dev/docs/load#input-methods-depends
You would need to test this out as I haven't used it yet.
Is this related to the issue? https://github.com/sveltejs/kit/issues/6854 or https://github.com/sveltejs/kit/issues/6800 If so, the problem belongs to Sveltekit.
I would assume it is a SvelteKit problem, since typesafe-i18n
does not make any network calls.