liveBook · Manning

Deep linking

As explained in Build Python Web Apps with Streamlit

A deep link is a URL that opens an application directly at a specific resource, view, or state.

Deep linking lets someone copy a URL that reopens an application at a specific resource, view, or state. For a dashboard, it replaces screenshots and error-prone instructions with a shareable link that preserves selections such as dates, filters, and chart settings. section 7.6

Sharing a dashboard view

A URL such as https://duckduckgo.com/?t=h_&q=streamlit&ia=web embeds the search input q=streamlit. A Streamlit dashboard applies the same idea: store widget values in URL query parameters, then restore those values when another user opens the link. section 7.6

Implement deep linking in two directions:

  • Read query parameters and use them to populate widget values during the initial app load. section 7.6 section 7.6.3
  • Write changed widget values back to the URL so the current dashboard state remains shareable. section 7.6.3
  • Give shareable widgets keys beginning with w:, separating URL-controlled values from other session-state entries. section 7.6.3
  • Restore defaults only when a key is absent from session state; otherwise, reruns would overwrite user changes. section 7.6.3
  • Serialize values deliberately: encode lists with L# and dates with D#, then decode them when reading the URL. section 7.6.3

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains URL embedding, widget restoration, session-state guards, reruns, and serialization through implementation examples.
Examples
Uses a DuckDuckGo search URL and dashboard controls for dates, comparisons, filters, grouping, and time grain.
What it assumes
Assumes an existing Streamlit dashboard with widgets and session-state values to synchronize.
What you can do after
Build it from scratch with Streamlit's st.query_params, session state, keyed widgets, and explicit value encoding.
How it connects
Connects URL query parameters with Streamlit widgets and session state.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.