Expand description
Clerk authentication for Dioxus 0.7: components, hooks, server-function context readers, and SSR initial auth state for web (WASM) and fullstack (Axum) apps.
§Quick start (web-only SPA)
Mount ClerkProvider at the app root, then gate content with SignedIn
/ SignedOut and drop in Clerk’s prebuilt widgets:
ⓘ
use dioxus::prelude::*;
use dioxus_clerk::*;
fn App() -> Element {
rsx! {
ClerkProvider { publishable_key: "pk_test_...",
SignedOut { SignInButton { class: "btn" } }
SignedIn { UserButton {} }
}
}
}§Fullstack (Axum)
Enable the server feature on the native build to verify Clerk sessions in
#[server] functions with current_auth(), installed by the
ClerkAuthLayer tower middleware. SSR initial auth state lets the client
hydrate without a flash of unauthenticated content.
ⓘ
#[server]
async fn whoami() -> Result<String, ServerFnError> {
use dioxus_clerk::server::current_auth;
Ok(current_auth()?.user_id)
}§Reactive hooks
use_auth, use_user, and use_session expose reactive auth state to
any descendant of ClerkProvider; use_clerk returns a lifecycle-aware
action facade for imperative flows.
§Feature flags
| Feature | Default | Enables |
|---|---|---|
| (none) | ✅ | Client components, hooks, guards, Clerk widgets, and SSR consumption. |
server | Axum middleware, extractors, #[server] context readers, and SSR initial-state helpers. Enable on the native server build only. | |
worker | server plus Send-wrapped middleware futures for single-threaded Cloudflare Workers. | |
testing | Test helpers (TestClerk) that mint Clerk-shaped session tokens locally. Enable under [dev-dependencies] only. |
Re-exports§
pub use components::AuthButtonMode;pub use components::ClerkFailed;pub use components::ClerkFailed;pub use components::ClerkLoaded;pub use components::ClerkLoaded;pub use components::ClerkLoading;pub use components::ClerkLoading;pub use components::ClerkProvider;pub use components::ClerkProvider;pub use components::CreateOrganization;pub use components::CreateOrganization;pub use components::OrganizationList;pub use components::OrganizationList;pub use components::OrganizationProfile;pub use components::OrganizationProfile;pub use components::OrganizationSwitcher;pub use components::OrganizationSwitcher;pub use components::Protect;pub use components::Protect;pub use components::RedirectToSignIn;pub use components::RedirectToSignIn;pub use components::RedirectToSignUp;pub use components::RedirectToSignUp;pub use components::SignIn;pub use components::SignIn;pub use components::SignInButton;pub use components::SignInButton;pub use components::SignOutButton;pub use components::SignOutButton;pub use components::SignUp;pub use components::SignUp;pub use components::SignUpButton;pub use components::SignUpButton;pub use components::SignedIn;pub use components::SignedIn;pub use components::SignedInWhenLoaded;pub use components::SignedInWhenLoaded;pub use components::SignedOut;pub use components::SignedOut;pub use components::SignedOutWhenLoaded;pub use components::SignedOutWhenLoaded;pub use components::TaskSetupMFA;pub use components::TaskSetupMFA;pub use components::UserAvatar;pub use components::UserAvatar;pub use components::UserButton;pub use components::UserButton;pub use components::UserProfile;pub use components::UserProfile;pub use components::Waitlist;pub use components::Waitlist;pub use core::AuthRequirement;pub use core::AuthState;pub use core::AuthStatus;pub use core::ClerkError;pub use core::OtherReverificationLevel;pub use core::OtherStatus;pub use core::OtherTaskKey;pub use core::ReverificationLevel;pub use core::Session;pub use core::SessionStatus;pub use core::SessionTask;pub use core::SessionTaskKey;pub use core::User;pub use hooks::ClerkActions;pub use hooks::SessionState;pub use hooks::UseAuth;pub use hooks::UseAuthOptions;pub use hooks::UseSession;pub use hooks::UseUser;pub use hooks::UserState;pub use hooks::use_auth;pub use hooks::use_auth_with_options;pub use hooks::use_clear_clerk_error;pub use hooks::use_clerk;pub use hooks::use_clerk_error;pub use hooks::use_session;pub use hooks::use_user;pub use options::ClerkOptions;pub use options::CreateOrganizationOptions;pub use options::GetTokenOptions;pub use options::JsonOptions;pub use options::OrganizationListOptions;pub use options::OrganizationProfileOptions;pub use options::OrganizationSwitcherOptions;pub use options::RedirectOptions;pub use options::Routing;pub use options::SignInOptions;pub use options::SignOutOptions;pub use options::SignUpOptions;pub use options::TaskSetupMFAOptions;pub use options::UserButtonOptions;pub use options::UserProfileMode;pub use options::UserProfileOptions;pub use options::WaitlistOptions;pub use serde_json;
Modules§
- components
- Drop-in components.
- core
- Advanced shared auth types, errors, and verification outcomes.
- guides
- Long-form guides, rendered from the Markdown sources in the repository’s
docs/directory. - hooks
- Reactive accessors for descendants of
ClerkProvider. - options
- Clerk options mapping: typed option builders for Clerk JS calls.
- prelude
- The everyday imports:
use dioxus_clerk::prelude::*;. - server
server - Server-side glue for Clerk in Dioxus fullstack apps.
- ssr
- Shared SSR initial state schema and lifecycle helpers.
- testing
testing - Test helpers for applications that authenticate with Clerk through this crate.
Structs§
- UseReverification
- Reactive handle returned by
use_reverification, mirroring Clerk React’suseReverification.
Functions§
- use_
reverification - Guard sensitive actions behind Clerk step-up reverification.