Router

class Router(source)

The class responsible for navigating to different pages in a user's app.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard

A simple data class containing information about a route.

Properties

Link copied to clipboard

A sequence of all routes registered with this router.

Functions

Link copied to clipboard

If set, get a chance to modify the page's route before Kobweb navigates to it.

Link copied to clipboard
fun navigateTo(pathQueryAndFragment: String, updateHistoryMode: UpdateHistoryMode = UpdateHistoryMode.PUSH, openInternalLinksStrategy: OpenLinkStrategy = OpenLinkStrategy.IN_PLACE, openExternalLinksStrategy: OpenLinkStrategy = OpenLinkStrategy.IN_NEW_TAB)

Like tryRoutingTo but handle the external navigation as well.

Link copied to clipboard
fun register(route: String, pageMethod: PageMethod)

Register a route, mapping it to some target composable method that will get called when that path is requested by the browser.

Link copied to clipboard
fun registerRedirect(fromRoute: String, toRoute: String)
Link copied to clipboard
@Composable
fun renderActivePage(pageWrapper: @Composable (@Composable () -> Unit) -> Unit = { it() })

Render the active page composable.

Link copied to clipboard
fun setErrorHandler(errorPageMethod: ErrorPageMethod)

Set a handler to call to render a page when the route is not found.

Link copied to clipboard
fun tryRoutingTo(pathQueryAndFragment: String, updateHistoryMode: UpdateHistoryMode = UpdateHistoryMode.PUSH, openLinkStrategy: OpenLinkStrategy = OpenLinkStrategy.IN_PLACE): Boolean

Attempt to navigate internally within this site, or return false if that's not possible (i.e. because the path is external).