Back button doesn't work with elements synced with query params
Author: davidhu-openaiCreated Feb 7, 2026Updated Sep 16, 2026
Labelstype:enhancementpapercutarea:frontendfeature:query-params
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
When pressing the browser back button, the streamlit script does not reexecute, so elements synced with st.query_params do not refresh
Reproducible Code Example
import streamlit as st
num_elements = 10
st.set_page_config(page_title="Mock element Slider", layout="centered")
element_ids = [f"mock-element-{i:02d}" for i in range(num_elements)]
element_to_idx = {element_id: idx for idx, element_id in enumerate(element_ids)}
url_element_id = st.query_params.get("element_id")
if (
"mock_element_id" not in st.session_state
or st.session_state["mock_element_id"] not in element_to_idx
):
st.session_state["mock_element_id"] = (
url_element_id if url_element_id in element_to_idx else element_ids[0]
)
with st.container(key="mock-element-slider"):
st.select_slider(
"element",
options=element_ids,
key="mock_element_id",
label_visibility="collapsed",
)
st.query_params["element_id"] = st.session_state["mock_element_id"]
current_element_id = st.session_state["mock_element_id"]
current_idx = element_to_idx[current_element_id]
with st.popover(f"element `{current_element_id}`"):
st.markdown(f"({current_idx}/{num_elements})")
Steps To Reproduce
- Create a streamlit app with the above code, and go to http://localhost:8501/?element_id=mock-element-3
- Drag the element to mock-element-5
- Press the browser back button.
Expected Behavior
You would expect the slider to go back to mock-element-3
Current Behavior
The slider stays at mock-element-5
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version:
- Python version:
- Operating System:
- Browser:
Additional Information
I've previously seen https://github.com/streamlit/streamlit/issues/9279, which looks related but is different and doesn't resolve this issue
Source: streamlit/streamlit