svelte-navigator
svelte-navigator copied to clipboard
Roadmap v4
V4 should make the router usable for more use cases. I've been planing on adding a hash based history for a while now. But there are a few things standing in the way to do this properly. Although the hash history would be optional, you'd still need the default browser history, as well as the fallback memory history module, even though you'd never use them. I've setup a new repo, where the history modules will be developed (svelte-navigator-history).
As a result the Router API will need to change slightly. There will need to be different Routers, like a HashRouter and BrowserRouter, similar to react-routers API. That's the only way to not bundle all history modules for every project.
In more detail, for v4 I'm planning to finish these tasks:
- [x] Add more tests to ensure everything is still working as intended
- [ ] Add Router modules that are bound to a specific history
- [ ]
BrowserRouterusing the HTML5 History API - [ ]
HashRouterusing the hash fragment - [ ]
MemoryRouterfor testing and embedded widgets - [ ] A Router, that automatically falls back to a memory history when the browser history doesn't work. Maybe
AutoRouter
- [ ]
- [ ] Add a way to block navigation, so the loss of unsaved data can be prevented
- [ ] Make it possible to force a nested Router to act as a top-level Router, so it can be used to control a single widget on the page
- [ ] Write a migration guide (also for people coming from svelte-routing #13)
Do you not want to use https://github.com/ReactTraining/history ? The underlying history handler for react-router. Seems like that would take the issues out of routing, and focus on the actual value for svelte.
I've thought about it and I might switch to it in the future or during the development of v4. It also already implements blocking, so that would be a benefit as well.
I didn't do it for now because it handles a few things a little differently. It parses locations slightly differently and it does not implement the svelte store interface, so I'd need to write a wrapper for svelte-navigator. It was also kind of fun do build the module myself...
I guess it would be more maintainable to rely on the history package going forward, but I'll try to finish the v4 api first and then see if I'll switch the history module...