arnaudmiribel / streamlit-extras

Discover, try, install and share Streamlit re-usable bits we call "extras"!
https://extras.streamlit.app
Apache License 2.0
737 stars 125 forks source link

✨ [IDEA] - Adding support for query parameters in switch_page #200

Closed ItsNiceCraft closed 9 months ago

ItsNiceCraft commented 10 months ago

Description

It would be perfect if it was possible to pass query parameters either by including them in the page title or adding them as a new argument in the switch_page function. A great use case of this would be switching to a sub page after clicking a button on a main page that passes on data to the sub page.

Minimal code for the extra

No response

Screenshots

No response

arnaudmiribel commented 9 months ago

Hey @ItsNiceCraft, sorry for not responding earlier. Did you end up with a solution here?

I'm curious about your use-case. The way we typically solve the "pass data across pages" problem is through usage of st.session_state. Is this not working for you for some reason?

ItsNiceCraft commented 9 months ago

I am using query parameters because they are easy to link to from places outside of the app, like the bookmark bar. I could look into switching to the session state method however.

Arnaud @.***> schrieb am Mittwoch, 3. Januar 2024 um 14:21:

Hey @.***(https://github.com/ItsNiceCraft), sorry for not responding earlier. Did you end up with a solution here?

I'm curious about your use-case. The way we typically solve the "pass data across pages" problem is through usage of st.session_state. Is this not working for you for some reason?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

arnaudmiribel commented 9 months ago

Sounds good. To be clear, I think the two work well together! You may read query params to initialize the state of your app from the URL (which, I agree, is very convenient). But then you may store those in st.session_state so they're shared throughout pages! Closing this