addRouteInterceptor
If set, get a chance to modify the page's route before Kobweb navigates to it.
This could be a cheap way to redirect to a new URL if an old one was removed due to a refactor.
A simple way to use this might look like:
@InitKobweb
fun initKobweb(ctx: InitKobwebContext) {
ctx.router.addRouteInterceptor {
if (path == "/admin") {
// The old admin has grown and is being split up into multiple pages.
// Send people to the dashboard by default.
path = "/admin/dashboard"
}
}
}
Content copied to clipboard
In the above case, if a user navigates to https://yoursite.com/admin
the URL will automatically change to https://yoursite.com/admin/dashboard
.
See RouteInterceptorScope for more options.