Expand description
Reactive authentication context for Orbital applications.
This module gives Orbital apps one shared place to store the current
AuthSession and a lightweight refresh token used to refetch it from the
server. Most apps provide it once near the router root and then access it with
use_auth_context, use_auth_state, or use_authenticated_user.
§Typical setup
ⓘ
use leptos::prelude::*;
use orbital::{init_auth_resource, provide_auth_context, AuthSession};
#[component]
fn AppRoot() -> impl IntoView {
let auth = provide_auth_context(AuthSession::default());
let _session_resource = init_auth_resource(auth.clone());
view! { <main>"App shell"</main> }
}After a sign-in, sign-out, or account change, call AuthContext::trigger_refresh
to ask the client-side session resource to load the latest backend session state.
Structs§
- Auth
Context - Shared authentication context containing session state and refresh controls.
Functions§
- provide_
auth_ context - Provide
AuthContextto the component tree and return it. - use_
auth_ context - Access the shared
AuthContext. - use_
auth_ state - Reactive memo for the current
AuthSession. - use_
authenticated_ user - Reactive memo for the authenticated user profile, if present.