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:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.