Upgrading to 0.20.11
Breaking changes
Zod version
If you use Zod params, upgrade from Zod 3 to Zod 4.0.0 and update affected schemas. See Zod Param Types.
Rejection definitions
Replace the rejections object with an array of definitions created by createRejection. Apply this to router and plugin options.
ts
// Before
const router = createRouter(routes, {
rejections: { AuthNeeded: AuthNeededView },
})
// After
const authNeeded = createRejection({
type: 'AuthNeeded',
component: AuthNeededView,
})
const router = createRouter(routes, {
rejections: [authNeeded],
})See Rejections.
Route callback context
Route props callbacks use the route's declared context for typed navigation and rejection helpers. Add referenced routes and rejections to context. Register route hooks through methods on the created route.
ts
const account = createRoute({
name: 'account',
path: '/account',
context: [login],
})
account.onBeforeRouteEnter((_to, { push }) => {
if (!isSignedIn()) {
push('login')
}
})See Context. The current route itself is automatically included beginning in 0.21.0.
Deprecations
Plugin hook options
Move hook properties from createRouterPlugin options to methods on the returned plugin.
ts
// Before
const plugin = createRouterPlugin({ onBeforeRouteEnter: callback })
// After
const plugin = createRouterPlugin({})
plugin.onBeforeRouteEnter(callback)