# route

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/router/function-route/

**function** · [`ferroui-view`](/docs/0.5.0/api/ferroui-view/) · v0.5.0

```rust
fn route(pattern: &str, view: impl Fn(&RouteMatch) -> crate::element::Element + 'static) -> RouteDef
```

A route: a pattern of segments separated by `/`, where `:name` matches one
segment and binds it to the parameter `name`, `*` matches the rest of the
path (and comes last), and any other segment matches itself. `view` makes
the element of the route from what the pattern matched.

```ignore
route("/", |_| rsx! { Home {} })
route("/people/:id", |m| rsx! { Person { id: m.param("id").unwrap_or_default().to_string() } })
route("*", |m| rsx! { TextBlock { text: format!("Nothing at {}", m.path()) } })
```
## Panics
When a segment follows `*`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/router.rs#L144)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
