Programmatic redirects within multipage apps

I’m currently transitioning a script to work as a multipage app now that we have support for pages right within streamlit - hooray!

With this new model, I’d like to be able to programmatically redirect a user back away from a page that’s not ready for them yet - this could be because they haven’t authenticated, or it might be that they haven’t uploaded data etc on a previous page.

Suppose I have …

.
├── pages
│   ├── 01_uploader.py
│   ├── 02_viewer.py
│   └── etc
└── streamlit_app.py

… and the user visits <myurl>/viewer (they may have bookmarked this, perhaps) without having previously been to <myurl>/uploader. I can easily enough make the page display nothing, but what’s the streamlit-y way to programmatically redirect them back to <myurl> or to <myurl>/uploader without causing a complete script re-run and a loss of session state?

1 Like

I have the same problem here. If you find the solution make a contact with me please.