Upgrading to 0.21.0
Breaking changes
Hook registration
Lifecycle hook options are removed from route, router, and plugin factories. Register hooks through methods on the returned object. Route and router option deprecation began in 0.20.8; plugin option deprecation began in 0.20.11.
// Before
const home = createRoute({
name: 'home',
path: '/',
onBeforeRouteEnter: callback,
})
// After
const home = createRoute({
name: 'home',
path: '/',
})
home.onBeforeRouteEnter(callback)Use router.onBeforeRouteEnter(callback) and plugin.onBeforeRouteEnter(callback) for global hooks. Apply the same change to the other enter, update, and leave hooks. See Hooks.
URL template helpers
path, query, and host are removed. Replace all three with withParams, as described in 0.17.3.
Registered and hook types
The registered helper types deprecated in 0.20.8 are removed. Infer method types from your router, for example typeof router.push.
Hook types now distinguish enter, update, and leave lifecycles. Replace broad BeforeRouteHook or RouterBeforeRouteHook annotations with the relevant BeforeEnterHook, BeforeUpdateHook, or BeforeLeaveHook; use the corresponding After*Hook types for after hooks. The matching context types follow the same naming pattern. Prefer inferred callback arguments when registering hooks directly.
RouteHookRemove, BeforeRouteHookLifecycle, AfterRouteHookLifecycle, and RouteHookLifecycle become HookRemove, BeforeHookLifecycle, AfterHookLifecycle, and HookLifecycle.