- Upgrade all depedencies.
- Upgrade all depedencies.
- Revert to commonjs (remove
type: "module"
) to keep support for cjs in node and esm in browsers.
- Upgrade all dependencies.
- Switch from babel to swc for dist compilation.
- fix redirects - the history was not ready by the time initial transition was kicked off by redirecting
- remove the possibility to pass the current route via the
merge
option directly, instead setmerge: true
(truthy value works now), and instead optionally pass the current route as the second argument tonavigate(to, curr)
orhref(to, curr)
, this is a breaking change, but also an undocumented API as it it's still being refined and is used for correctly merging urls during async navigations.
- fix the
navigate(url: string)
implementation where"".replace
was being tested instead ofto.replace
- re-introduce
navigate(url: string)
since it's nice and convenient
- refer to
setImmediate
viaglobal.setImmediate
to fix a webpack compilation error
- allow passing current route as
merge
value to opt out of using current url and using an externally passed in route, useful in async context where reading current URL might not be safe
A rewrite of space-router. It's better now!
- less methods (only
listen
,navigate
,match
,href
andgetUrl
) - simpler function signatures and simpler listen callback - you just get the route, not route+data
- improved route config format with objects (
path
,redirect
,routes
) instead of arrays - redirects feature
- new docs at https://kidkarolis.github.io/space-router/
All in all - it's a new API, but it's spiritually very much the same and is the best version of Space Router yet!
- Improvement - Add
replace(url, options)
in addition topush
, because it matches the DOM API closer and the names are semantically meaningful. - Improvement - Add
set(options)
, which unlikepush/replace
, can be used to only update specific bits of the url, e.g.set({ query: { a: 1 } })
would add a=1 into the query string in addition to what's already there. Setquery
orhash
tonull
to clear them. - Improvement - Add
match(url)
, which matches the provided url against the route config and returns{ route, data }
, useful in Server Side Rendering. - Breaking change - remove
route.path
in favor of the newroute.href
.
- Improvement - Add
route.href
in favor ofroute.path
, which was too close toroute.pathname
and therefore confusing.