mefechoel / svelte-navigator

Simple, accessible routing for Svelte
Other
506 stars 39 forks source link

Accessing active route outside of router #96

Open rehmulus opened 1 year ago

rehmulus commented 1 year ago

In my project I'd like to have a navigation with subnavs that are outside of the route itself and differ for each route. Currently I use a wrapper component in each route that calls useLocation and saves it to a store so I can access the active path and see when it changes.

I think a cleaner solution would be to expose activeRoute in Router.svelte

Locally, I have got it to work by adding export to activeRoute declaration (and adding a line to Router.d.ts) but I don't know if it has any side effects.