Quick setup
Wrap your app (or its authenticated subtree) withAilitaProvider. It handles tenant
discovery, theme injection, and token refresh automatically.
Props
Public client key for this tenant (e.g.
"pk_live_abc123"). Used as the primary lookup key
in GET /auth/discovery?clientId= on mount. The backend validates this against a registered
domain allowlist using the browser-supplied Origin header. Changing this prop re-runs discovery.Merchant subdomain slug (e.g.
"sanfernando"). Optional — sent alongside clientId for
audit logging on the backend. Not used as a security identifier.Base URL of the API, e.g.
https://api.yourdomain.com/api/v1. Set once before discovery
runs. All subsequent API calls use this base URL.Called when the refresh token is invalid and tokens are cleared. Redirect to
/login here.
Treat as required — without it, users silently lose their session with no recovery path.
The 401 refresh queue in client.ts fires this callback after a failed refresh attempt.Rendered while discovery is in progress. Defaults to
null (blank screen). Provide a
spinner or skeleton to avoid a content flash on mount.Rendered if discovery fails (network error, unknown slug). Defaults to
null. Provide
an error state that prompts the user to refresh or contact support.How discovery works
On mount,AilitaProvider runs the following sequence:
- Sets the Axios base URL to your
baseUrlprop - Calls
GET /auth/discovery?clientId={clientId}to fetch tenant configuration - Receives tenant data: name, colors,
loginMode,signupMode,publicApiKey - Injects
X-App-IDandX-Mid-Keyheaders into all subsequent API requests via an Axios interceptor
The backend uses
clientId to look up the tenant and validates the request Origin header
against that tenant’s registered domain allowlist. Auth requests from unregistered domains
are rejected with 403. This is the primary defense against tenant impersonation.Internal composition
AilitaProvider composes three layers internally. Consumers never need to instantiate
ThemeProvider or AuthProvider directly.
loginMode and signupMode
Your tenant’sloginMode and signupMode are returned by the discovery endpoint and
control which UI flows LoginForm and SignupForm render.
loginMode
| Value | Behavior |
|---|---|
PASSWORD | Standard email + password login |
OTP_EMAIL | Login via one-time code sent to email (no password) |
PASSWORD_OR_OTP_EMAIL | User chooses between password or email OTP |
signupMode
| Value | Behavior |
|---|---|
OPEN | Anyone can register |
INVITATION_ONLY | Registration requires an invitation link |
These values are returned by the discovery endpoint and set automatically. Your tenant’s
loginMode and signupMode are configured in the ailita backend admin panel — you do not
need to pass them as props.Next steps
Protect routes with AuthGuard
Require authentication or specific roles before rendering protected UI.

