Multi-page app (ver. 1.36)

I redesigned my app to be multi-page. Pages navigation and other features work fine, but when the user is not on the main page and presses the refresh or F5 button, the page freezes and doesnโ€™t display any content.

Hi @Vyacheslav!

Could you share a link to your repo, or a minimal reproducible script that shows how you are setting up the main page, and the setting page?

Are you using the setup with a pages/ folder, or using the new st.navigation?

Actually, it looks like this is a known issue that will be fixed in the next release Page not reloading when using st.navigation() ยท Issue #8986 ยท streamlit/streamlit ยท GitHub

Can you try installing streamlit-nightly and see if that fixes the issue for you?

1 Like

I use st.navigation

import streamlit as st
import streamlit_authenticator as stauth
import yaml
from yaml.loader import SafeLoader

st.set_page_config(page_title="dashboard", layout="wide", page_icon=":bar_chart:")  

if "role" not in st.session_state:
    st.session_state.role = None

my_kpi_page = st.Page("userpages/", title="My KPI", icon= "๐Ÿ“ถ")
settings_page = st.Page("adminpages/", title="Settings", icon="๐Ÿ”‘")
empty_page = st.Page("userpages/", title=None, icon=None,default=True)

def get_page_by_role(role_user):

    pages = None
    if (role_user == "admin"):
        pages = {
             "Main" : [my_kpi_page],
             "Settings": [settings_page]
        pages = [empty_page]
        return pages
    return pages

def main():

    with open('./config.yaml') as file:
        config_ath = yaml.load(file, Loader=SafeLoader)
        cred_dict = config_ath['credentials']
        cookie = config_ath['cookie']

    authenticator = stauth.Authenticate(cred_dict,
                                        cookie_expiry_days = cookie["expiry_days"]
    name, authenticator_status, username = authenticator.login()

    if authenticator_status == False:
            st.error("Username/password is incorrect")
            st.session_state.role = None

    if authenticator_status == None:
        st.warning("Please enter username and password")
        pages_user = get_page_by_role(None)
        pg = st.navigation(pages_user)
        st.session_state.role = None

    if authenticator_status:
        group_user = (cred_dict['usernames'][st.session_state["username"]]["group"])      

        st.session_state.role = group_user
        st.sidebar.write(f"Login: {username}")
        authenticator.logout("Logout", "sidebar")

        pages_user = get_page_by_role(st.session_state.role)
        pg = st.navigation(pages = pages_user , position="sidebar")

if __name__ == '__main__':
    hide_st_style = """
                #MainMenu {visibility: hidden;}
                footer {visibility: hidden;}
    st.markdown(hide_st_style, unsafe_allow_html=True)

Thanks :smiley: