Skip to content

Flicker/Double Load of Login Screen with streamlit-authenticator on App Startup #263

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Open
ShikharUser opened this issue Feb 26, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@ShikharUser
Copy link

I'm encountering a flicker/double load issue on startup when using the streamlit-authenticator-mongo package for authentication in my Streamlit app. The problem is that when a user first visits the app, the session state for authentication (st.session_state["authentication_status"]) is initially None, which triggers the login screen. Shortly after, the authentication process sets this value to True (for authenticated users), and the app re-runs, switching to the main screen. This results in the following sequence:

  1. Initial Run:

st.session_state["authentication_status"] is None.
The code treats this as an unauthenticated state and displays the login screen.

  1. Subsequent Run:
    The authentication library updates st.session_state["authentication_status"] to True.
    The app re-runs and displays the main UI.

This causes a brief but noticeable flicker where the login screen appears before the main content is rendered, even if the user is already authenticated.

    menu = ["Login", "Register"]
    choice = st.sidebar.selectbox("Menu", menu)
    if choice == "Login":
        authenticator.login('Login', 'main')
    elif choice == "Register":
        # Registration form logic...```
@mkhorasani mkhorasani added the enhancement New feature or request label Feb 26, 2025
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants