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 running as an application with marimo run.

marimo.query_params() QueryParams

Get the query parameters of a marimo app.

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. If you mutate this object, changes will be persisted to the frontend query parameters and any other cells referencing the query parameters will automatically re-run.

CLI arguments

You can also access command-line arguments passed to the notebook using mo.cli_args. This allows you to pass arguments to the notebook that are not controllable by the user.