1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! 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:
//!
//! ```rust,ignore
//! 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.
//!
//! ```rust,ignore
//! #[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. |
//!
//! [Dioxus]: https://dioxuslabs.com
// docs.rs passes --cfg docsrs (see [package.metadata.docs.rs]) and builds on
// nightly, where doc_cfg renders feature-requirement badges.
// Curated crate-root re-exports. These lists are explicit (rather than glob
// re-exporting the modules) so the stable surface is reviewable and a new
// `pub` item in a module does not silently land at the crate root. Advanced
// types (`ClerkAuth`, `VerificationOutcome`, `InvalidTokenReason`) stay under
// `crate::core`; `crate::prelude` re-exports the everyday subset.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Re-export of the exact [`serde_json`] this crate builds against.
///
/// [`serde_json::Value`] appears in the public prop surface of the Clerk widget
/// components (the `options`/`appearance`/`localization`/… escape hatches) and
/// in the `impl Into<serde_json::Value>` option arguments on the hooks, so
/// `serde_json` is part of this crate's semver contract. Build your option
/// values through this re-export to stay in lockstep with the version the
/// components deserialize with.
pub use serde_json;
// Client-side browser modules. `clerk_client` (emitted by build.rs) means
// wasm32 without the `worker` feature. The gate excludes `worker` rather than
// `server` so features stay additive: a browser-wasm build keeps the client
// path even when the `server` feature unifies in; only the explicit `worker`
// opt-in (server-on-wasm) drops it.
/// Reset page-scoped `Clerk.load()` state between wasm integration tests.
///
/// Hidden test-support hook: a mock whose load promise never settles (e.g. a
/// pending-load fixture) leaves the in-flight flag set, which would make the
/// next test's provider block in the load-in-flight wait loop. Real clerk-js
/// always settles, so this never matters outside tests.
///
/// Not part of the public API. The `__` prefix and `#[doc(hidden)]` mark it as
/// an internal hook the crate's own (external) wasm integration tests reach;
/// it is excluded from this crate's semver guarantees and may change or be
/// removed at any time.
// Pure publishable-key decoding for the client loader. Compiled under `test`
// too so its logic is covered by host `cargo test`, not only the CI-only wasm
// suite.