Skip to content
Discussion options

You must be logged in to vote

Add a state variable like AuthState.is_logged_in: bool = False. Set to True only once the user is logged in. Reset state on logout.

To avoid a blank page, return something else than your page if user is not logged in:

def my_page() -> rx.Component:
    return rx.cond(
        ~AuthState.is_logged_in,
        rx.spinner(),
        rx.box(
            # your actual page content
        )
    )

In your page on_load function you can check the auth state as well and redirect to a login page if the user isn't authenticated yet. Otherwise start the background task, etc.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by fabiog1901
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@masenf
Comment options

@fabiog1901
Comment options

@fabiog1901
Comment options

@masenf
Comment options

@fabiog1901
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants