Query parameters don't work in streamlit cloud

Hi guys,

I am using query parameters to store and share application state.

When developing locally everything seems to work but once deployed to streamlit cloud st.experimental_get_query_params() returns an empty object.

The URL looks like this

Locally:
http://localhost:8501/?a=1&b=2

Streamlit cloud:
https://share.streamlit.io/<username>/<project_name>/?a=1&b=2

There is another forum post about this issue but the explained solution did not work for me and also sounds a bit strange.

Best regards,
Nico

1 Like

Hi @nflaig, and welcome to the Streamlit community! :raised_hands:

Would it be possible for you to share the code to try on our end?

Many thanks,
Charly

Hi @Charly_Wargnier,

thanks for the reply :slight_smile:

I created a simplified version of my application to showcase the issue.

Streamlit cloud URL: https://share.streamlit.io/nflaig/st-query-params-test
Github repository: GitHub - nflaig/st-query-params-test: Application to test streamlit query params

The problem is that the initial query params are empty when running the application in streamlit could but it works perfectly fine when running it locally.

https://share.streamlit.io/nflaig/st-query-params-test?a=1&b=2 => initial query params: {}

http://localhost:8501/?a=1&b=2 => initial query params: { "a": "1", "b": "2"}

Also it has to be noted that I had to write the initial query params into st.session_state else the application would behave unexpectedly when setting new query params. This is related to already exisiting forum post and github comment/issue. So my best guess right now that st.session_state works somehow differently in streamlit cloud then locally but I am not sure how I can fix the issue on my side.

Edit: I switched from streamlit built-in sessions state (st.session_state) to the custom session state solution described here which seems to fix the issue.

Best regards,
Nico

Hi @Charly_Wargnier,

were there any major changes recently in streamlit cloud? Query params are broken again. There seems to be a new query parameter timestamp which is not set by my application but overwrites existing parameters. You can verify this behavior by using the following link to my application: https://share.streamlit.io/nflaig/st-query-params-test?a=1&b=2.

Best regards,
Nico

Thank you for raising this @nflaig ! We will address this within the next 24 hours.

1 Like

Hi @Alex_Toader,

good news, query parameters seem to work now which can be verified using st-query-params-test app. But one strange thing that happens now is that it reloads the whole page if query params change and it shows Please wait... on the screen. Any clue if those things are related?

Best regards,
Nico

Hi @nflaig ! We’ve made a recent change in this area. @kmcgrady could this be related to the optimization we made around how we process parameters?

Hey @nflaig I am not sure if it’s related, but I am looking into a solution to something possibly similar. Will let you know when the issue is fixed.

1 Like

Hey, @nflaig let me know if you see an improvement. I push some changes out and did some testing to make sure it works just like streamlit. I tested your app with it, and everything looks fine to me. Let me know if you see any issues.

1 Like

LGTM! Thanks for the fast fix

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.