Teaches: provide_auth_context + init_auth_resource, RequireAuthenticated route gate, and theme mode / density toggles persisted to localStorage.
Topology: Embedded demo session (in-memory AuthSession). Swap the Sign in handler for your session server function in production.
# cargo install cargo-leptos # once
export LEPTOS_OUTPUT_NAME=authenticated-dashboardcargo leptos watch --split --project authenticated-dashboardOpen http://127.0.0.1:3031/:
- Visit
/dashboardwhile signed out → auth-required gate. - Sign in → reopen
/dashboard→ protected card. - Toggle Dark / Compact → refresh → prefs restore.
Compile-check:
cargo check -p authenticated-dashboard --features ssrOpen first: src/app.rs → src/theme_prefs.rs
Success: gate blocks anonymous /dashboard; after Sign in the dashboard card renders; theme/density survive reload.
Next step: ../server-paged-analytics for server-paged DataTable + chart.