Query Parameters#
Use mo.query_params
to access query parameters passed to the notebook. You can also
use mo.query_params
to set query parameters in order to keep track of state in the
URL. This is useful for bookmarking or sharing a particular state of the notebook while in running as an application.
- marimo.query_params() QueryParams #
Get the query parameters.
Examples:
Keep the text input in sync with the URL query parameters
# In it's own cell query_params = mo.query_params() # In another cell search = mo.ui.text( value=query_params["search"] or "", on_change=lambda value: query_params.set("search", value), ) search
You can also set the query parameters reactively:
toggle = mo.ui.switch(label="Toggle me") toggle # In another cell query_params["is_enabled"] = toggle.value
Returns:
A
QueryParams
object containing the query parameters. You can directly interact with this object like a dictionary, and it will persist changes to the frontend query parameters.