How can I share a link to a streamlit app where upon click, the user is taken to a specifically chosen dropdown option. I thought about using query params in the url but I tried it here and it didn’t work out as expected.
What I am trying to do is say you have an app with dropdown with hundreds of options and you want to discuss a specific one with a user. Right now, I am sharing a link to the app and telling the user to navigate to the specific option in the dropdown. I would rather share the app link and have them open it to the exact dropdown selection of interest. Does that make sense?
If I understand the problem, once a user has selected a option you want them to be able to return to that option without having to select it from the drop down again.
I can’t see how that could be done by modifying the URL - but you should be able to do it by setting a COOKIE.
Can you give an example to set a cookie to accomplish this?
I am not sure why whatt i want sounds so odd. Imagine a dropdown selection call it “option W” and you want to share a link directly to this chosen option like “www.my-streamlit-app.com/?dropdown_selection=option_W”. Wouldn’t this be feasible? Again if ther is a better way, i am open to it but to me it seems stupid to share a link to “www.my-streamlit-app.com” and ask the user to go fishing for a certain option in the dropdown when there are hundreds of options to choose from.
An interesting problem. I have an app to pick a stock from a list of symbols and display the stock information. I decided to see if I could modify it so I can send a query string with the stock symbol and go right to that page. This seems to work for me.
You may have this already - but you need a null case for when there is no query string:
query_string = st.experimental_get_query_params()
if not query_string :
query_string =
Then I needed to bypass the sidebar dropdown:
if not self.query_string :
symbol = st.sidebar.selectbox(‘Select Stock’, (stock_symbols))
else :
symbol = query_string[‘symbol’][0]
symbol = symbol.strip(’`’)
Finally, I wanted to get back to the page with the drop down so I could pick a stock other than the one in the query string. I added this to the bottom of the page: