Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter-SvelteKit: missing domain based strategy #280

Open
maurictg opened this issue Dec 23, 2024 · 1 comment
Open

Adapter-SvelteKit: missing domain based strategy #280

maurictg opened this issue Dec 23, 2024 · 1 comment

Comments

@maurictg
Copy link

Currently for the SvelteKit adapter we have no option to use domain-based strategy as is possible for Next see docs. Are there any plans to implement this for SvelteKit too or is there any workaround/way to do it right now?

Copy link
Member

samuelstroschein commented Dec 23, 2024

No plans at the moment to support domain based routing in SvelteKit.

You can create your own domain based routing already with plain Paraglide JS. Out of my head (likely needs tweaking!):

  1. Have an AsyncLocalStorage in a server handle hook.
  2. Set the language to a getter of the async local storage setLanguageTag(() => asyncStorage.getStore())
  3. Detect the language of the user based on the domain in a server handle hook.
  4. Wrap the return value of the handle hook with asyncStorage.run()
  5. Call setLanguageTag() on the client (best in the root component, most often the layout) with the detected language

Plans exist with Paraglide JS 2.0 to have a guide for this, and generally recommend people to use their own routing solution. The opinionated structure of the current SvelteKit adapter is unmaintainable. People have all sorts of edge cases. It's better to have a good abstraction (as Paraglide JS already is!) and guide developers to write a bit of code themselves that they control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants