def LoginSample():
    """Sample app for testing login/logout with LocalStorage var."""
    import reflex as rx

    class State(rx.State):
        auth_token: str = rx.LocalStorage("")

        @rx.event
        def logout(self):
            self.set_auth_token("")

        @rx.event
        def login(self):
            self.set_auth_token("12345")
            yield rx.redirect("/")

    def index():
        return rx.cond(  # pyright: ignore [reportCallIssue]
            State.is_hydrated & State.auth_token,  # pyright: ignore [reportOperatorIssue]
            rx.vstack(
                rx.heading(State.auth_token, id="auth-token"),
                rx.button("Logout", on_click=State.logout, id="logout"),
            ),
            rx.button("Login", on_click=rx.redirect("/login"), id="login"),
        )

    def login():
        return rx.vstack(
            rx.button("Do it", on_click=State.login, id="doit"),
        )

    app = rx.App()
    app.add_page(index)
    app.add_page(login)
Sample app for testing login/logout with LocalStorage var.
tests/integration/test_login_flow.py