Redirect Component #50
Replies: 3 comments
-
+1 I had to use same component, exactly how you have it here. |
Beta Was this translation helpful? Give feedback.
-
Hey there and thanks for your interest! The reason why there is no redirect component in svelte-navigator is because it would need to work both client and server side. When server side rendering a page using svelte-navigator, the library knows nothing about the rest of your server stack, so it can't make any assumptions on how to best redirect anywhere. Some SSR or SSG framework might be able to solve that, but this simple library just can't do that. So for consistencies sake and because you can implement a redirect component yourself, just like you did, it is not included in the lib. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, Same here this works perfectly, I was trying to replicate the behavior or React Router's Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Hi @mefechoel,
you did some great work here.
I run accross an IMHO unsolved need for the
svelte-navigator
.Sometimes you just want to redirect when getting to a specific
Route
.e.G. when you navigate to
my-app.com/user
you want to see the user details which are accesible undermy-app.com/user/details
.Therefore i created a tiny
Redirect.svelte
component in my app:… which should be a child of Route …
I'm curious how your approach would look like for this scenario and if your interested in a PR for this component.
Greetings Kai
Beta Was this translation helpful? Give feedback.
All reactions