For a project I needed to build multi-page app with a settings page. As I’ve seen this topic requesting the feature, I decided to share the solution I came up with. It features a custom version of @thiago’s SessionState.
It still relies on hacks, but it should work in most cases. It was tested with Streamlit version 0.61.0 (and now 0.65).
Things you must be aware of before using it:
You must call
state.sync()at the end of your app if you set a widget’s default value to a state variable. This function triggers a rerun if you store a new state value or update an already stored object. This is how I fix rollback issues when you interact with widgets bound to a state value. In my demo I call it at the end of
If I start to drag a slider, 1 second later the mouse is released, probably because of my rerun