Routes¶
- marimo.routes(routes: dict[str, Union[Callable[[], object], Callable[[], Coroutine[NoneType, NoneType, object]], object]]) Html ¶
Renders a list of routes that are switched based on the URL path.
Routes currently don’t support nested routes, or dynamic routes (e.g.
#/user/:id
). If you’d like to see these features, please let us know on GitHub: https://github.com/marimo-team/marimo/issuesFor a simple-page-application (SPA) experience, use should use hash-based routing. For example, prefix your routes with
#/
.If you are using a multi-page-application (MPA) with
marimo.create_asgi_app
, you should use path-based routing. For example, prefix your routes with/
.Examples.
mo.routes( { "#/home": render_home(), # not lazily evaluated "#/about": render_about, "#/contact": render_contact, } )
Args.
routes
: a dictionary of routes, where the key is the URL path and the value is a function that returns the content to display.
Returns.
An
Html
object.