v3.0.0
Breaking Change!!
We've changed the way absolute paths are handled, greatly simplifying the code implementation and resulting in a much improved developer experience and performance.
Migrating from Version 2
To migrate from version 2.0.0 to version 3.0.0, prepend /
to all paths in your RouteConfig. This change enhances consistency and clarity in defining routes.
Why this change?
In previous versions, there was inconsistency in how paths were defined. Some paths started with /
while others didn't, leading to confusion. Version 3.0.0 standardizes this by requiring all paths to be absolute, making the route definitions more intuitive and easier to understand.
Migration Steps
-
Update Route Definitions
In version 3.0.0, ensure all paths start with
/
.Before version 2.0.0:
const routeConfig = { home: { path: '/' }, users: { path: 'users/:userid' } products: { path: 'products', children: { search: { path: 'search/?size&color' } } } } as const satisfies RouteConfig;
Version 3.0.0:
const routeConfig = { home: { path: '/', }, users: { path: '/users/:userid', }, products: { path: '/products', children: { search: { path: '/search/?size&color', }, }, }, } as const satisfies RouteConfig;
Now, all paths are prefixed with
/
. -
Handling Absolute Paths
This migration is optional and will continue to work as expected with previous versions.
In previous versions, absolute paths required the Route ID to be prefixed with
*
. In version 3.0.0, this is no longer necessary, though the*
prefix will still work for compatibility.Before version 2.0.0:
const routeConfig = { '*external': { path: 'https://', children: { youtube: { path: 'youtube.com', children: { watch: '/watch?videoid', }, }, }, }, };
Version 3.0.0:
const routeConfig = { 'external': { path: 'https://', children: { youtube: { path: 'youtube.com', children: { watch: '/watch?videoid', }, }, }, }, };
Summary
Make sure you precede all relative paths in RouteConfig with a '/'.