Skip to main content

Module auth

Module auth 

Source
Expand description

Built-in auth + viewer state management for forge-dioxus.

Handles token storage, viewer persistence, refresh loops, and 401 recovery. Apps get viewer access for free without writing their own storage layer.

Re-exports§

pub use ForgeAuthProvider_completions::Component::ForgeAuthProvider;

Structs§

ForgeAuth
Auth handle provided to components via use_forge_auth().
ForgeAuthProviderProps
Properties for the ForgeAuthProvider component.

Enums§

ForgeAuthState

Functions§

ForgeAuthProvider
Provider component that sets up auth state, ForgeClient with auto token wiring, 401 detection, and periodic refresh.
use_auth_key
Returns a string key that changes on login/logout transitions. Use this to key your router or main content area so SSE subscriptions reconnect with fresh auth state.
use_forge_auth
Read the auth handle from context.
use_require_auth
Guard hook: redirects to redirect_path when unauthenticated. Returns true if authenticated, false during redirect.
use_viewer
Read the stored viewer, deserialized into the app’s viewer type. Returns None when unauthenticated or if the viewer hasn’t been set.