BrowserRouter

data object BrowserRouter : Router(source)

A router leveraging the History API (https://developer.mozilla.org/en-US/docs/Web/API/History).

Using a BrowserRouter requires you to implement a catch-all to send the same resource for every path the router intends to control. BrowserRouter will handle the proper child composition.

Without a catch-all rule, will get a 404 or "Cannot GET /path" error each time you refresh or request a specific path. Each server's implementation of a catch-all will be different, and you should handle this based on the webserver environment you're running.

For more information about this catch-all, check your webserver implementation's specific instructions. For development environments, see the RoutingCompose Readme for full instructions.

Functions

Link copied to clipboard
open override fun currentPath(): Path

The current path

Link copied to clipboard
@Composable
open override fun getPath(initPath: String): State<String>
Link copied to clipboard
@Composable
operator fun Router.invoke(initRoute: String, routing: @Composable RouteBuilder.() -> Unit)
Link copied to clipboard
open override fun navigate(to: String, hide: Boolean, replace: Boolean)

Navigate to a new path.

Link copied to clipboard
fun Router.navigate(to: String, parameters: Parameters, hide: Boolean = false, replace: Boolean = false)
fun Router.navigate(to: String, parameters: Map<String, String>, hide: Boolean = false, replace: Boolean = false)
fun Router.navigate(to: String, parameters: Map<String, List<String>>, hide: Boolean = false, replace: Boolean = false)