Changing page

I need to change page page depending on a variable value.
For example if x = 1 it will change the app to another page.
I can do it with button I know but I need it to be automatically without button.
Thanks in advance

You can do with with streamlit-extras

import streamlit as st
from streamlit_extras.switch_page_button import switch_page

x = st.slider("x", 0, 10)

if x == 1:
    switch_page("page1")

Is there any documentation of how to make the second page?

1 Like

If you create a pages folder next to your main_app.py file, then any .py file in the pages folder will be another page.

Hey @Abdelrahman_Mahmoud Abdel, :wave:

Just wanted to update that with release 1.30.0 you can now natively program page switching using st.switch_page() as well as disable the sidebar navigation. :balloon:

More info in the docs . Looking forward to hearing what you think!

1 Like