Description
Describe the problem
For i18n or similar subsystems, we should make initialization before any language things are needed, and for such initialization, we usually use a session (user language) and information from the HTTP request.
Before the new routing system was introduced, we were using the root __layout.svelte to do it, it's working well for SSR and CSR time.
I should mention that what i18n should be inited on the server side and init on the client side as well (or state should be send as is).
After migration to new routing, we lose one "transitional" place to init such thing because +layout.js
can be called after +page.js
, and you must do await parent()
in each page to avoid such race condition.
For server-side only init, we have a good place it's handle
in hooks.js
with event.locals
it's an excellent way to init server only things like DB connection, but for things what should be a transition from SSR to CSR we have no place.
I also have a similar issue for i18n implementation project what I use cibernox/svelte-intl-precompile#55
Describe the proposed solution
Maybe it's possible to do it more straightforwardly, but at least we need a global hook for what will be called on SSR and on CSR, after +layout.server.js
but before +layout.js
and +page.js
.
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response