---
title: React SDK
description: 'Public React SDK components, hooks and types, generated from the SDK source.'
canonical_url: 'https://saaslayer.com/docs/reference/react/'
last_updated: '2026-11-21T21:40:59-08:00'
---
# React SDK

## Checked example

This example is included from typechecked source. Complete the
[integration guide](https://saaslayer.com/docs/getting-started/agents) for your deployment and framework.

```tsx
import { SignIn } from '@saaslayer/react'

// Render inside your app's configured SaaSLayerProvider.
export function SignInPanel() {
  return <SignIn />
}
```

Reference for **@saaslayer/react 0.0.17**. Generated from this version's public exports and TypeScript declarations. Signatures describe the API; the integration guides explain behavior and setup.

## AcceptInvitation

```ts
export declare function AcceptInvitation({ token, appearance, onAccepted, signedOut }: AcceptInvitationProps): React.JSX.Element;
```

## AcceptInvitationProps

```ts
export interface AcceptInvitationProps {
    token: string;
    appearance?: Appearance;
    onAccepted?: (result: {
        orgId: string;
        grants: InvitationGrant[];
        userId: string;
    }) => void;
    signedOut?: ReactNode;
}
```

## AccessRequests

```ts
export declare function AccessRequests({ userId: userIdProp, client: clientProp, appearance: appearanceProp, onError }: AccessRequestsProps): React.JSX.Element;
```

## AccessRequestsProps

```ts
export interface AccessRequestsProps {
    userId?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## AccountPortal

```ts
export declare const AccountPortal: {
  (props: AccountPortalProps): ReactNode;
  "Page": PartComponent<{ id: string; label: string; children?: ReactNode; }>;
};
```

## AccountPortalPage

A host-injected section: \<AccountPortal.Page id="x" label="…">…\</AccountPortal.Page>.

```ts
export declare const AccountPortalPage: {
  (props: { id: string; label: string; children?: ReactNode; }): ReactNode | Promise<ReactNode>;
  "partName": string;
  "propTypes": any;
  "displayName": string | undefined;
};
```

## AccountPortalProps

```ts
export interface AccountPortalProps {
    appearance?: Appearance;
    mode?: 'page' | 'modal';
    sections?: AccountPortalSection[];
    children?: ReactNode;
}
```

## AccountPortalSection

The built-in, backed sections.

```ts
export type AccountPortalSection = 'profile' | 'organizations' | 'apiKeys' | 'passkeys';
```

## ApiKeys

```ts
export declare function ApiKeys({ client: clientProp, appearance: appearanceProp, onError }: ApiKeysProps): React.JSX.Element;
```

## ApiKeysProps

```ts
export interface ApiKeysProps {
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## Appearance

```ts
export interface Appearance {
    variables?: Partial<Record<AppearanceVar, string>>;
    colorScheme?: ColorScheme;
    elements?: Record<string, ElementOverride>;
    layout?: {
        logoPlacement?: 'none' | 'top';
        socialButtonsPlacement?: 'top' | 'bottom';
    };
}
```

## appearanceCssVars

Map appearance.variables to a CSS-custom-property style object for the widget root.

```ts
export declare function appearanceCssVars(appearance?: Appearance): CSSProperties;
```

## AppearanceVar

The documented, stable set of theme tokens. Hosts set any subset; the rest fall back to the default CSS.

```ts
export type AppearanceVar = 'colorPrimary' | 'colorText' | 'colorBackground' | 'colorDanger' | 'colorBorder' | 'borderRadius' | 'fontFamily' | 'spacingUnit' | 'colorTextMuted' | 'colorSurface' | 'colorBorderSubtle' | 'colorFocus' | 'colorSuccess' | 'colorWarning';
```

## AuditLog

```ts
export declare function AuditLog({ scope: scopeProp, client: clientProp, appearance: appearanceProp, pageSize, onError }: AuditLogProps): React.JSX.Element;
```

## AuditLogProps

```ts
export interface AuditLogProps {
    scope?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    pageSize?: number;
    onError?: (err: Error) => void;
}
```

## AuthorizeDebugger

```ts
export declare function AuthorizeDebugger({ client: clientProp, action: actionProp, resource: resourceProp, product, service, appearance: appearanceProp }: AuthorizeDebuggerProps): React.JSX.Element;
```

## AuthorizeDebuggerProps

```ts
export interface AuthorizeDebuggerProps {
    client?: PermissionsClient;
    action?: string;
    resource?: string;
    product?: string;
    service?: string;
    appearance?: Appearance;
}
```

## back

Pop one page; a no-op at the root (the stack never empties).

```ts
export declare function back(state: VirtualRouterState): VirtualRouterState;
```

## Boundaries

```ts
export declare function Boundaries({ client: clientProp, appearance: appearanceProp, onError }: BoundariesProps): React.JSX.Element;
```

## BoundariesProps

```ts
export interface BoundariesProps {
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## Can

Render `children` only if the caller is allowed. `permission` takes one input or a list (combined by
`match`); `action`/`resource` are sugar for a single check. Children may be a render function
`(&#123; allowed, loading, reason &#125;) =&#62; ...` to disable + explain instead of hide.

```ts
export declare function Can({ children, fallback, denied, ...spec }: CanProps): React.JSX.Element;
```

## CanFn

```ts
export interface CanFn {
    (action: string, resource: string): boolean | undefined;
    (permission: PermissionInput): boolean | undefined;
    all(list: PermissionInput[]): boolean | undefined;
    any(list: PermissionInput[]): boolean | undefined;
    reason(permission: PermissionInput): string | null | undefined;
}
```

## CanProps

```ts
export interface CanProps extends GateSpec {
    children: GateChildren;
    fallback?: ReactNode;
    denied?: ReactNode;
}
```

## clearScope

Remove the persisted scope (best-effort). Never throws.

```ts
export declare function clearScope(): void;
```

## collectParts

Collect, in source order, the props of every child that is the given part. Non-matching children ignored.

```ts
export declare function collectParts<P>(children: ReactNode, part: PartComponent<P>): P[];
```

## completeCheck

Complete a check with its product + service: the check's own, else the gate's, else the provider default. A check
that still names neither is a developer error (the server rejects it: a deployment serves several products).

```ts
export declare function completeCheck(c: PermissionCheckInput, fallback?: DecisionTargetDefaults): PermissionCheck;
```

## CreateOrganization

```ts
export declare function CreateOrganization({ client: clientProp, appearance: appearanceProp, onCreated, title }: CreateOrganizationProps): React.JSX.Element;
```

## CreateOrganizationProps

```ts
export interface CreateOrganizationProps {
    client?: PermissionsClient;
    appearance?: Appearance;
    onCreated?: (org: OrgCreated) => void;
    title?: string;
}
```

## createPart

Define a compound part. The returned component renders null — the PARENT collects its props via
collectParts and decides what to render. `partName` identifies it across module/bundle boundaries.

```ts
export declare function createPart<P>(partName: string): PartComponent<P>;
```

## createScopeStore

A scope store over `options.session`.

```ts
export declare function createScopeStore(options: ScopeStoreOptions): ScopeStore;
```

## current

```ts
export declare function current(state: VirtualRouterState): string;
```

## DecisionTargetDefaults

The provider-level default decision target (SaaSLayerConfig product/service).

```ts
export interface DecisionTargetDefaults {
    product?: string;
    service?: string;
}
```

## decodeJwtPayload

Decode a JWT payload (base64url) without verifying — returns \{} on any error.

```ts
export declare function decodeJwtPayload(token: string): Record<string, unknown>;
```

## defaultScope

The default active scope for a user: their primary org (the token hint), no project selected yet.

```ts
export declare function defaultScope(user: SaaSLayerUser | null): Scope;
```

## DeploymentDiscovery

```ts
export interface DeploymentDiscovery {
    contractVersion: number;
    deploymentId: string;
    revision: string | null;
    region: string;
    userPoolId: string;
    clientId: string;
    issuer: string;
    audience: string[];
    jwksUrl: string;
    hostedLoginUrl: string;
    usersApiBase: string;
    permissionsApiBase: string;
    passwordlessApiBase: string | null;
}
```

## DeploymentDiscoveryError

```ts
export interface DeploymentDiscoveryError {
  "code": string;
  "output"?: string | undefined;
  "status"?: number | undefined;
  "name": string;
  "message": string;
  "stack"?: string | undefined;
  "cause"?: unknown;
}
export declare const DeploymentDiscoveryError: {
  new (code: string, message: string, extra?: { output?: string; status?: number; }): DeploymentDiscoveryError;
};
```

## deploymentDiscoveryUrl

```ts
export declare function deploymentDiscoveryUrl(target: DiscoveryTarget): string;
```

## DISCOVERY_CONTRACT_VERSION

```ts
export declare const DISCOVERY_CONTRACT_VERSION: 2;
```

## DiscoveryInstances

```ts
export interface DiscoveryInstances {
    'user-service'?: string;
    'permissions-service'?: string;
}
```

## DiscoveryTarget

```ts
export type DiscoveryTarget = {
    url: string;
    refreshSeconds?: number;
} | {
    apiBase: string;
    deploymentId: string;
    instances?: DiscoveryInstances;
};
```

## EffectivePermissions

```ts
export declare function EffectivePermissions({ userId: userIdProp, principalType, scope: scopeProp, client: clientProp, appearance: appearanceProp, onError }: EffectivePermissionsProps): React.JSX.Element;
```

## EffectivePermissionsProps

```ts
export interface EffectivePermissionsProps {
    userId?: string;
    principalType?: string;
    scope?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## ELEMENT_IDS

```ts
export declare const ELEMENT_IDS: readonly ["card", "header", "notices", "form", "formFields", "formActions", "formField", "formFieldHeader", "formFieldHeaderAction", "formFieldControl", "formFieldAction", "formFieldHint", "headerTitle", "headerSubtitle", "footer", "footerActionLink", "formFieldLabel", "formFieldInput", "formFieldError", "formButtonPrimary", "formButtonSecondary", "alertError", "spinner", "logo", "signIn", "signUp", "mfaCodeInput", "socialButtons", "socialButton", "connectedAccounts", "mfaEnrollment", "mfaStepUp", "mfaRecoveryCodes", "mfaQrCode", "mfaSecret", "userButtonTrigger", "userButtonAvatar", "userButtonPopoverCard", "userButtonMenuItem", "userProfile", "organizationSwitcher", "organizationSwitcherTrigger", "organizationSwitcherPopover", "organizationSwitcherOrgList", "organizationSwitcherProjectList", "organizationSwitcherActions", "organizationPreview", "projectPreview", "organizationProfile", "roleSelect", "inviteButton", "inviteLink", "impersonationBanner", "viewAsControl", "roleEditor", "roleEditorRoleItem", "roleEditorMatrix", "roleEditorResourceRow", "roleEditorPermissionCell", "roleEditorRawToggle", "auditLog", "auditLogFilters", "auditLogRow", "auditLogLoadMore", "createOrganization", "organizationInvitations", "invitationRow", "accountPortal", "accountPortalNav", "apiKeys", "apiKeyRow", "apiKeyScopeOption", "effectivePermissions", "effectivePermissionRow", "effectivePermissionsSummary", "passkeys", "passkeyRow", "passkeyReauth", "accessRequests", "accessRequestRow", "authorizeDebugger", "authorizeDecision", "groups", "groupItem", "groupMemberRow", "userGrants", "grantRow", "boundaries", "boundaryRow", "ssoSettings", "ssoSetup", "ssoSecret", "menu", "menuItem", "dialog", "dialogTitle", "dialogDescription", "dialogActions", "tabs", "tabList", "tab", "tabPanel", "popover", "select", "switch", "checkbox", "toast", "section", "sectionHeader", "sectionTitle", "sectionDescription", "sectionActions", "list", "listRow", "listRowMain", "listRowTitle", "listRowSubtitle", "listRowMeta", "listRowActions", "badge", "emptyState", "loadingState", "toolbar", "buttonDanger", "buttonGhost"];
```

## ElementId

```ts
export type ElementId = (typeof ELEMENT_IDS)[number];
```

## ElementOverride

Per-element override: either extra class names or an inline style object, keyed by data-sl-el id.

```ts
export type ElementOverride = string | CSSProperties;
```

## elementProps

Compute the \{ className, style, \['data-sl-el'] } for a rendered element by its stable id. Always sets
the base `sl-&#60;id&#62;` class + the data-sl-el attribute (the public theming hook); a host override is
appended (string => extra classes; object => inline style). Component-provided extraClass is merged.

```ts
export declare function elementProps(appearance: Appearance | undefined, id: string, extraClass?: string): { className: string; style?: CSSProperties; "data-sl-el": string; part?: string; };
```

## fetchDeploymentDiscovery

```ts
export declare function fetchDeploymentDiscovery(target: DiscoveryTarget, options?: { fetch?: typeof fetch; }): Promise<DeploymentDiscovery>;
```

## ForgotPassword

```ts
export declare function ForgotPassword({ appearance, onDone, onBackToSignIn, phoneLogin: ownPhone, passwordReset }: ForgotPasswordProps): React.JSX.Element;
```

## ForgotPasswordProps

```ts
export interface ForgotPasswordProps {
    appearance?: Appearance;
    onDone?: () => void;
    onBackToSignIn?: () => void;
    phoneLogin?: PhoneLoginOptions;
    passwordReset?: PasswordResetOptions;
}
```

## GateSpec

Props a gate accepts to describe what it requires.

```ts
export interface GateSpec {
    permission?: PermissionInput | PermissionInput[];
    action?: string;
    resource?: string;
    product?: string;
    service?: string;
    scope?: string;
    match?: 'all' | 'any';
}
```

## GateState

The resolved decision for a gate. `allowed` is undefined while loading / signed out.

```ts
export interface GateState {
    allowed: boolean | undefined;
    loading: boolean;
    error: Error | null;
    reason: string | null;
}
```

## Groups

```ts
export declare function Groups({ workspaceId: workspaceIdProp, client: clientProp, appearance: appearanceProp, onError }: GroupsProps): React.JSX.Element;
```

## GroupsProps

```ts
export interface GroupsProps {
    workspaceId?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## IMPERSONATION_PERMISSION

The registered impersonation permission (`product:service:type:action`).

```ts
export declare const IMPERSONATION_PERMISSION: "saaslayer:users:account:impersonate";
```

## ImpersonationBanner

Always-visible while impersonating: "Viewing as X" + a Stop action. Renders nothing otherwise.

```ts
export declare function ImpersonationBanner({ appearance, children }: ImpersonationBannerProps): React.JSX.Element | null;
```

## ImpersonationBannerProps

```ts
export interface ImpersonationBannerProps {
    appearance?: Appearance;
    children?: (info: {
        email: string | null;
        effectiveUserId: string | null;
    }) => ReactNode;
}
```

## impersonationCheck

The check that gates starting a view-as in `orgId`: on one target (`account/&#60;suid&#62;`) or on login accounts in general.

```ts
export declare function impersonationCheck(orgId: string, targetSuid?: string): PermissionCheck;
```

## ImpersonationTarget

The person a session views as, the org the impersonation is bounded to, and the mode asked for at the start.

```ts
export interface ImpersonationTarget {
    targetSuid: string;
    orgId: string;
    mode?: ImpersonationMode;
}
```

## initRouter

```ts
export declare function initRouter(initial: string): VirtualRouterState;
```

## isKnownElementId

True when an id is part of the frozen public registry.

```ts
export declare function isKnownElementId(id: string): boolean;
```

## loadScope

Read the persisted active scope, or null if absent/unavailable/corrupt. Never throws.

```ts
export declare function loadScope(): Scope | null;
```

## mergeAppearance

Merge a per-widget appearance onto the provider-level default (widget wins per field).

```ts
export declare function mergeAppearance(base?: Appearance, override?: Appearance): Appearance | undefined;
```

## MfaEnrollment

TOTP enrollment (Cognito-direct via the connector) followed by a one-time recovery-code display. The
recovery codes are shown exactly once (D5) — from the user-service — and the user confirms they saved them.
Opted-in deployments: a credential still pending MFA then completes its enrollment (completeIdentityMfa), which signs
that method out, so the session ends and the user signs in again.

```ts
export declare function MfaEnrollment({ appearance, onEnrolled }: MfaEnrollmentProps): React.JSX.Element;
```

## MfaEnrollmentGate

Blocks its children behind MFA enrollment when policy requires it and the user has not enrolled (D18).
Renders \<MfaEnrollment> until enrollment completes, then reveals the app.

```ts
export declare function MfaEnrollmentGate({ appearance, children }: MfaEnrollmentGateProps): React.JSX.Element | null;
```

## MfaEnrollmentGateProps

```ts
export interface MfaEnrollmentGateProps {
    appearance?: Appearance;
    children: ReactNode;
}
```

## MfaEnrollmentProps

```ts
export interface MfaEnrollmentProps {
    appearance?: Appearance;
    onEnrolled?: () => void;
}
```

## MfaState

The resolved MFA posture for the current user.

```ts
export interface MfaState {
    loading: boolean;
    required: boolean;
    enrolled: boolean;
    methods: string[];
    reload: () => Promise<void>;
}
```

## navigate

Push a page (no-op if it's already current).

```ts
export declare function navigate(state: VirtualRouterState, page: string): VirtualRouterState;
```

## nonPartChildren

The children that are NOT any of the given parts (a widget renders these as free content).

```ts
export declare function nonPartChildren(children: ReactNode, parts: PartComponent<unknown>[]): ReactNode[];
```

## normalizePermission

Parse one permission input into a check. Throws on a malformed compact string (a developer error).

```ts
export declare function normalizePermission(input: PermissionInput): PermissionCheckInput;
```

## OrganizationInvitations

```ts
export declare function OrganizationInvitations({ orgId: orgIdProp, appearance: appearanceProp }: OrganizationInvitationsProps): React.JSX.Element;
```

## OrganizationInvitationsProps

```ts
export interface OrganizationInvitationsProps {
    orgId?: string;
    appearance?: Appearance;
}
```

## OrganizationProfile

```ts
export declare const OrganizationProfile: {
  (props: OrganizationProfileProps): ReactNode;
  "Page": PartComponent<{ label: string; children?: ReactNode; }>;
};
```

## OrganizationProfilePage

A host-injected custom tab: \<OrganizationProfile.Page label="Billing">…\</OrganizationProfile.Page>.

```ts
export declare const OrganizationProfilePage: {
  (props: { label: string; children?: ReactNode; }): ReactNode | Promise<ReactNode>;
  "partName": string;
  "propTypes": any;
  "displayName": string | undefined;
};
```

## OrganizationSwitcher

```ts
export declare const OrganizationSwitcher: {
  (props: OrganizationSwitcherProps): ReactNode;
  "Action": PartComponent<{ children?: ReactNode; }>;
};
```

## OrganizationSwitcherAction

Host-injected action shown at the foot of the popover (e.g. "Create organization").

```ts
export declare const OrganizationSwitcherAction: {
  (props: { children?: ReactNode; }): ReactNode | Promise<ReactNode>;
  "partName": string;
  "propTypes": any;
  "displayName": string | undefined;
};
```

## parseUser

Build a SaaSLayerUser from an ID token, honoring impersonation via the canonical discrete claims
(custom:as_suid / as_org / as_email — §5.0.3). The principal (userId) is the impersonated suid when
present, so gating evaluates as the effective user; realUserId keeps the actual signed-in principal.

```ts
export declare function parseUser(idToken: string | null): SaaSLayerUser | null;
```

## PartComponent

A part component: renders nothing itself (it is config the parent reads) but carries a stable partName.

```ts
export interface PartComponent<P> extends FunctionComponent<P> {
    partName: string;
}
```

## Passkeys

```ts
export declare function Passkeys({ discovery, appearance: appearanceProp, onError }: PasskeysProps): React.JSX.Element;
```

## PasskeysProps

```ts
export interface PasskeysProps {
    discovery?: DiscoveryConfig | null;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## PasswordResetOptions

Greenfield reset-email protocol. Base64URL only obscures the identifier; the backend validates the proof.

```ts
export interface PasswordResetOptions {
    emailDelivery?: 'code' | 'link';
    handleRedirect?: boolean;
}
```

## PermissionBatcher

```ts
export interface PermissionBatcher {
    request(check: PermissionCheck): Promise<PermissionResult>;
    peek(check: PermissionCheck): PermissionResult | undefined;
    subscribe(listener: () => void): () => void;
    getVersion(): number;
}
```

## PermissionCheckInput

A check as written by the app: product/service may come from the gate or the provider config instead.

```ts
export type PermissionCheckInput = Omit<PermissionCheck, 'product' | 'service'> & {
    product?: string;
    service?: string;
};
```

## PermissionInput

One permission, compact-string or explicit-object form.

```ts
export type PermissionInput = string | PermissionCheckInput;
```

## PhoneLoginOptions

How the phone login method is offered (opted-in deployments with phone ready): the country picker and the SMS disclosure.

```ts
export interface PhoneLoginOptions {
    countries?: string[];
    brandName?: string;
    privacyPolicyUrl?: string;
    termsUrl?: string;
    retentionNotice?: string;
}
```

## Protect

Route/section guard (Clerk-parity): renders `children` only when the caller is allowed the requirement
in the active scope, else `fallback` (also shown while loading — a guard never flashes the content).
Accepts the same polymorphic `permission`/`match` (or action/resource) as \<Can>.

```ts
export declare function Protect({ children, fallback, ...spec }: ProtectProps): React.JSX.Element;
```

## ProtectProps

```ts
export interface ProtectProps extends GateSpec {
    children: ReactNode;
    fallback?: ReactNode;
}
```

## providerConfigFromDiscovery

The \<SaaSLayerProvider> config a discovery document describes, plus the app's own defaults.

```ts
export declare function providerConfigFromDiscovery(doc: DeploymentDiscovery, appDefaults?: Pick<SaaSLayerConfig, "product" | "service" | "socialRedirectUri">): SaaSLayerConfig;
```

## reset

Replace the whole stack with a single page (e.g. jump to a top-level tab).

```ts
export declare function reset(state: VirtualRouterState, page: string): VirtualRouterState;
```

## resolveGate

Resolve a gate's props into the concrete checks + match mode. Precedence: explicit `action`/`resource`
sugar wins; else `permission` (single or array). Top-level `product`/`service`/`scope` fill in for any check
that doesn't carry its own, then the provider `defaults`. Returns an empty list when nothing is specified.

```ts
export declare function resolveGate(spec: GateSpec, defaults?: DecisionTargetDefaults): { checks: PermissionCheck[]; match: "all" | "any"; };
```

## RoleEditor

```ts
export declare function RoleEditor({ orgId: orgIdProp, client: clientProp, appearance: appearanceProp, isProtected, onError }: RoleEditorProps): React.JSX.Element;
```

## RoleEditorProps

```ts
export interface RoleEditorProps {
    orgId?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    isProtected?: (role: Role) => boolean;
    onError?: (err: Error) => void;
}
```

## SaaSLayerConfig

Config the host passes once, from its SaaSLayer instance coordinates (D26 connect flow).

```ts
export interface SaaSLayerConfig {
    region: string;
    userPoolId: string;
    clientId: string;
    permissionsApiBase: string;
    userServiceApiBase?: string;
    socialRedirectUri?: string;
    product?: string;
    service?: string;
    appName?: string;
}
```

## SaaSLayerConnector

The account/MFA self-service surface widgets call (signUp/reset/TOTP). CognitoDirectConnector satisfies it.

```ts
export type SaaSLayerConnector = AccountConnector & MfaConnector;
```

## SaaSLayerProvider

Wrap the app once. Owns the session, connector, appearance, and active scope for its subtree.

```ts
export declare function SaaSLayerProvider({ config, appearance, session, connector, discovery, secondaryConnector, phoneLogin, storage, initialScope, scopeStore, batchPermissions, children }: SaaSLayerProviderProps): React.JSX.Element;
```

## SaaSLayerProviderProps

```ts
export interface SaaSLayerProviderProps {
    config: SaaSLayerConfig;
    appearance?: Appearance;
    session?: Session;
    connector?: SaaSLayerConnector;
    discovery?: DiscoveryConfig | null;
    secondaryConnector?: SaaSLayerConnector;
    phoneLogin?: PhoneLoginOptions;
    storage?: TokenStorage;
    initialScope?: Scope;
    scopeStore?: ScopeStore;
    batchPermissions?: boolean;
    children: ReactNode;
}
```

## SaaSLayerUser

The SaaSLayer user derived from the verified ID token's claims (D27 contract).

```ts
export interface SaaSLayerUser {
    userId: string | null;
    realUserId: string | null;
    orgId: string | null;
    email: string | null;
    sub: string | null;
    impersonating: boolean;
    claims: Record<string, unknown>;
}
```

## saveScope

Persist the active scope (best-effort). Never throws.

```ts
export declare function saveScope(scope: Scope): void;
```

## ScopePreference

Where a viewer's pick is kept between page loads. `viewer` is null when picks are not kept per viewer.

```ts
export interface ScopePreference {
    load(viewer: string | null): Scope | null;
    save(viewer: string | null, scope: Scope): void;
}
```

## ScopeState

```ts
export interface ScopeState {
    scope: Scope;
    organizations: OrgRef[];
    projects: OrgRef[];
    loading: boolean;
    error: Error | null;
    listed: boolean;
    preparing: boolean;
    timedOut: boolean;
    generation: number;
}
```

## ScopeStore

```ts
export interface ScopeStore {
    getState(): ScopeState;
    subscribe(listener: () => void): () => void;
    select(next: Scope): Promise<void>;
    reload(): void;
}
```

## ScopeStoreOptions

```ts
export interface ScopeStoreOptions {
    session: Session;
    scopeMode?: 'account' | 'tab';
    userServiceApiBase?: string;
    permissionsApiBase?: string | (() => string | undefined);
    initialScope?: Scope;
    preference?: ScopePreference;
    fetch?: typeof fetch;
    wait?: (ms: number) => Promise<void>;
}
```

## SignedIn

How a sign-in completed: the login method of the credential and the way it was proven.

```ts
export interface SignedIn {
    loginMethod: LoginMethod;
    via: 'password' | 'social' | 'sso' | 'passkey' | 'magic-link' | 'sms-code';
    created?: boolean;
}
```

## SignIn

The sign-in surface. A deployment whose phone pool signs in through the user-service gateway gets the phone-code flow
(number -> code -> optional name; onSignedIn says whether the account was created); every other one the lanes below.

```ts
export declare function SignIn(props: SignInProps): React.JSX.Element;
```

## SignInProps

```ts
export interface SignInProps {
    passwordReset?: PasswordResetOptions;
    onSignedIn?: (signedIn: SignedIn) => void;
    title?: string;
    defaultUsername?: string;
    lockUsername?: boolean;
    defaultPassword?: string;
    appearance?: Appearance;
    autoCompleteMagicLink?: boolean;
    discovery?: DiscoveryConfig | null;
    phoneLogin?: PhoneLoginOptions;
    handleSocialRedirect?: boolean;
    socialMode?: SocialMode;
    onSocialError?: (error: SocialError) => void;
    redirect?: (url: string) => void;
    breakGlass?: boolean;
}
```

## SignInStep

The step of the sign-in flow (password + passwordless lanes).

```ts
export type SignInStep = 'password' | 'mfa' | 'newPassword' | 'resetPassword' | 'resetLinkSent' | 'resetSignIn' | 'magicLinkSent' | 'done';
```

## SignUp

```ts
export declare const SignUp: {
  (props: SignUpProps): ReactNode;
  "Page": PartComponent<{ children?: ReactNode; }>;
};
```

## SignUpInput

Credentials submitted to \{@link UseSignUp.signUp}: the identifier of the form's login method, and its password.

```ts
export interface SignUpInput {
    email?: string;
    phoneNumber?: string;
    password: string;
    orgName?: string;
}
```

## SignUpProps

```ts
export interface SignUpProps {
    appearance?: Appearance;
    collectOrgName?: boolean;
    onSignedUp?: () => void;
    autoSignIn?: boolean;
    phoneLogin?: PhoneLoginOptions;
    onSignInInstead?: () => void;
    onSignedIn?: (signedIn: SignedIn) => void;
    handleSocialRedirect?: boolean;
    socialMode?: SocialMode;
    onSocialError?: (error: SocialError) => void;
    children?: ReactNode;
}
```

## SignUpStep

The step of the sign-up flow.

```ts
export type SignUpStep = 'credentials' | 'verify' | 'done';
```

## Slot

`asChild` slot (Radix-style): merge the given props (className, style, handlers) onto the single child
element instead of rendering a wrapper — so a host can supply its own markup for a leaf button/link.

```ts
export declare function Slot({ children, ...slotProps }: { children: ReactNode; } & Record<string, unknown>): ReactElement;
```

## SocialButtons

"Continue with \{provider}" buttons for every enabled provider in the discovery descriptor. Renders
nothing when social login is not configured (no userServiceApiBase / no providers) — SRP + passwordless
remain the login surface. Each button links straight to the provider (skips the Cognito login page).

```ts
export declare function SocialButtons({ appearance, labelPrefix, discovery, fetch, redirect, store, onError, mode, onSocialError, openPopup }: SocialButtonsProps): React.JSX.Element | null;
```

## SocialButtonsProps

```ts
export interface SocialButtonsProps {
    appearance?: Appearance;
    labelPrefix?: string;
    discovery?: DiscoveryConfig | null;
    fetch?: typeof fetch;
    redirect?: (url: string) => void;
    store?: OAuthTransactionStore;
    onError?: (error: Error) => void;
    mode?: SocialMode;
    onSocialError?: (error: SocialError) => void;
    openPopup?: () => PopupWindow | null;
}
```

## SocialError

A social sign-in that did not complete: a popup outcome (`popup_blocked`, `popup_closed`, `popup_timeout`) or the callback's sanitized code.

```ts
export interface SocialError {
    code: string;
}
```

## SocialMode

How a social sign-in leaves the page: a full redirect, or a popup that relays the answer back.

```ts
export type SocialMode = 'redirect' | 'popup';
```

## SsoFactors

The SSO sign-in's second factors: list, add an authenticator app or a passkey, remove (after a step-up).

```ts
export declare function SsoFactors({ client: clientProp, required, appName, account, onSignInAgain, onChange, credentials, appearance }: SsoFactorsProps): React.JSX.Element;
```

## SsoFactorsProps

```ts
export interface SsoFactorsProps {
    client?: UserServiceClient;
    required?: boolean;
    appName?: string;
    account?: string;
    onSignInAgain?: () => void;
    onChange?: (factors: SsoFactor[]) => void;
    credentials?: CredentialsContainer;
    appearance?: Appearance;
}
```

## SsoSettings

One SSO connection's settings, as far as the caller's access reaches.

```ts
export declare function SsoSettings({ connectionId, client: clientProp, permissionsClient: permissionsProp, mode, setupUrl, signInUrl, onSessionEnded, onError, appearance }: SsoSettingsProps): React.JSX.Element;
```

## SsoSettingsProps

```ts
export interface SsoSettingsProps {
    connectionId: string;
    client?: SsoManagementClient;
    permissionsClient?: PermissionsClient;
    mode?: 'manage' | 'setup';
    setupUrl?: string;
    signInUrl?: string;
    onSessionEnded?: () => void;
    onError?: (err: Error) => void;
    appearance?: Appearance;
}
```

## SsoSetup

The IT admin's setup page: one connection, setup steps only, for as long as the link's session lasts.

```ts
export declare function SsoSetup({ userServiceApiBase, fetch: fetchImpl, signInUrl, appearance }: SsoSetupProps): React.JSX.Element;
```

## SsoSetupProps

```ts
export interface SsoSetupProps {
    userServiceApiBase?: string;
    fetch?: typeof fetch;
    signInUrl?: string;
    appearance?: Appearance;
}
```

## SsoStepUp

Verify this SSO session with a current second factor: a code from the authenticator app, or a step-up passkey.

```ts
export declare function SsoStepUp({ client: clientProp, passkeys, credentials, onVerified, onCancel, appearance }: SsoStepUpProps): React.JSX.Element;
```

## SsoStepUpProps

```ts
export interface SsoStepUpProps {
    client?: UserServiceClient;
    passkeys?: boolean;
    credentials?: CredentialsContainer;
    onVerified: () => void;
    onCancel?: () => void;
    appearance?: Appearance;
}
```

## StepUpChallenge

A step-up challenge prompt: enter a TOTP code, use a one-time recovery code, or (when wired) a FIDO2
authenticator. TOTP/recovery are verified through the provided callbacks / the user-service; FIDO2 is a
seam (onFido2) because the WebAuthn ceremony needs

```ts
export declare function StepUpChallenge({ appearance, onSubmitCode, onFido2, onVerified }: StepUpChallengeProps): React.JSX.Element;
```

## StepUpChallengeProps

```ts
export interface StepUpChallengeProps {
    appearance?: Appearance;
    onSubmitCode?: (code: string) => Promise<void>;
    onFido2?: () => Promise<void>;
    onVerified?: () => void;
}
```

## useAuth

```ts
export declare function useAuth(): UseAuth;
```

## UseAuth

Reactive auth state + actions.

```ts
export interface UseAuth {
    status: AuthState['status'];
    isSignedIn: boolean;
    revoked: boolean;
    ssoSessionExpired: boolean;
    ssoEmail: string | null;
    emailChange: AuthState['emailChange'];
    emailChangedTo: AuthState['emailChangedTo'];
    signIn: (params: PasswordSignInParams) => Promise<void>;
    signOut: (options?: SignOutOptions) => Promise<void>;
    getPermissionsBearer: () => Promise<string | null>;
    refresh: () => Promise<void>;
}
```

## useCan

Imperative caller-scoped check, batched + cached like \<Can>. See module header for the call forms.

```ts
export declare function useCan(): CanFn;
```

## useConnector

The account/MFA connector for self-service ops (signUp/forgotPassword/TOTP) — used by the auth widgets.

```ts
export declare function useConnector(): SaaSLayerConnector;
```

## useDiscovery

Fetch + cache the public discovery descriptor for the configured userServiceApiBase (E1), or the provider's injected one.

```ts
export declare function useDiscovery(options?: { fetch?: typeof fetch; }): { config: DiscoveryConfig | null; loading: boolean; error: string | null; };
```

## useGate

Evaluate a set of checks for the signed-in caller, combining by `match` ('all' = every check passes,
'any' = at least one). Batched when a \<SaaSLayerProvider> batcher is present (each check coalesces into the
shared batch); otherwise one single check per item. Re-evaluates when the checks, match, or active project change.

```ts
export declare function useGate(checks: PermissionCheck[], match: "all" | "any"): GateState;
```

## useImpersonation

```ts
export declare function useImpersonation(): UseImpersonation;
```

## UseImpersonation

Reactive impersonation state + actions. The effective identity comes from useUser (the as\_\* claims).

```ts
export interface UseImpersonation {
    impersonating: boolean;
    realUserId: string | null;
    effectiveUserId: string | null;
    mode: ImpersonationMode | null;
    endsAt: number | null;
    impersonate: (target: ImpersonationTarget) => Promise<void>;
    stop: () => Promise<void>;
}
```

## useInvitations

An org's pending invitations (admin): list + create + revoke. Re-fetches on org change + reload().

```ts
export declare function useInvitations(orgId: string | null): UseInvitations;
```

## UseInvitations

```ts
export interface UseInvitations {
    invitations: Invitation[];
    loading: boolean;
    error: Error | null;
    reload: () => void;
    create: (input: {
        email: string;
        grants: InvitationGrant[];
        expiresAt?: string;
        delivery?: 'link' | 'email';
        inviterName?: string;
    }) => Promise<Invitation>;
    resend: (invitationId: string) => Promise<void>;
    revoke: (invitationId: string) => Promise<void>;
}
```

## useMfa

Resolve the MFA posture: prefer the authoritative user-service view (GET /api/profile/mfa) when a
user-service is configured; otherwise fall back to the custom:mfa claim + the discovery policy hint.

```ts
export declare function useMfa(): MfaState;
```

## useOrganization

The active org + project resolved from the current scope against the caller's own lists.

```ts
export declare function useOrganization(): UseOrganization;
```

## UseOrganization

```ts
export interface UseOrganization {
    organization: OrgRef | null;
    project: OrgRef | null;
    loading: boolean;
    error: Error | null;
}
```

## useOrganizationList

The signed-in caller's own orgs + projects: one list per scope store, read when a component first needs it, again
when the viewer or their org changes, and on reload().

```ts
export declare function useOrganizationList(): UseOrganizationList;
```

## UseOrganizationList

```ts
export interface UseOrganizationList {
    organizations: OrgRef[];
    projects: OrgRef[];
    loading: boolean;
    error: Error | null;
    preparing: boolean;
    timedOut: boolean;
    reload: () => void;
}
```

## usePermission

Ask "can I do this?" for the signed-in caller (single check). Product/service default to the provider config.
Re-checks when the check or sign-in changes.

```ts
export declare function usePermission(check: PermissionCheckInput): UsePermission;
```

## UsePermission

```ts
export interface UsePermission {
    allowed: boolean | undefined;
    loading: boolean;
    error: Error | null;
    reason?: string | null;
}
```

## usePermissionBatcher

The active batcher, or null when batching is disabled (gates then check one-by-one).

```ts
export declare function usePermissionBatcher(): PermissionBatcher | null;
```

## UserButton

```ts
export declare const UserButton: {
  (props: UserButtonProps): ReactNode;
  "MenuItems": PartComponent<{ children?: ReactNode; }>;
  "Action": PartComponent<{ label: string; onClick: () => void; icon?: ReactNode; }>;
  "Link": PartComponent<{ label: string; href: string; icon?: ReactNode; }>;
};
```

## UserButtonProps

```ts
export interface UserButtonProps {
    appearance?: Appearance;
    children?: ReactNode;
}
```

## UserGrants

```ts
export declare function UserGrants({ granteeId: granteeIdProp, client: clientProp, appearance: appearanceProp, onError }: UserGrantsProps): React.JSX.Element;
```

## UserGrantsProps

```ts
export interface UserGrantsProps {
    granteeId?: string;
    client?: PermissionsClient;
    appearance?: Appearance;
    onError?: (err: Error) => void;
}
```

## UserProfile

```ts
export declare const UserProfile: {
  (props: UserProfileProps): ReactNode;
  "Page": PartComponent<{ label: string; children?: ReactNode; }>;
};
```

## UserProfilePage

A host-injected custom tab: \<UserProfile.Page label="Billing">…\</UserProfile.Page>.

```ts
export declare const UserProfilePage: {
  (props: { label: string; children?: ReactNode; }): ReactNode | Promise<ReactNode>;
  "partName": string;
  "propTypes": any;
  "displayName": string | undefined;
};
```

## useSaaSLayerContext

Internal: read the context or throw a helpful error.

```ts
export declare function useSaaSLayerContext(): SaaSLayerContextValue;
```

## useScope

The active \{orgId, projectId} scope + a setter (the switcher calls setScope). With a user-service base, setting another
org switches it on the server and resolves once the session token carries it (it rejects when that is refused).

```ts
export declare function useScope(): { scope: Scope; setScope: (next: Scope) => Promise<void>; };
```

## useSignIn

```ts
export declare function useSignIn(options?: UseSignInOptions): UseSignIn;
```

## UseSignIn

Headless password sign-in: the flow state + the actions each step calls.

```ts
export interface UseSignIn {
    step: SignInStep;
    error: string | null;
    errorCode: string | null;
    submitting: boolean;
    passkeySigningIn: boolean;
    loginMethod: LoginMethod;
    loginMethods: LoginMethod[];
    selectLoginMethod: (method: LoginMethod) => void;
    mfaMethod: 'totp' | 'sms' | null;
    resetUsername: string;
    resetFromLink: boolean;
    resetNeedsRecovery: boolean;
    openPasswordResetLink: (proof: {
        email: string;
        code: string;
    }) => void;
    signIn: (params: PasswordSignInParams) => Promise<void>;
    submitMfaCode: (code: string) => Promise<void>;
    submitNewPassword: (newPassword: string) => Promise<void>;
    submitPasswordReset: (code: string | undefined, newPassword: string) => Promise<void>;
    resendResetCode: () => Promise<void>;
    startPasswordReset: (username: string) => Promise<void>;
    magicLinkEmail: string;
    requestMagicLink: (email: string) => Promise<void>;
    completeMagicLinkFromUrl: (url?: string) => Promise<void>;
    signInWithPasskey: (email?: string) => Promise<void>;
    reset: () => void;
}
```

## UseSignInOptions

Options for \{@link useSignIn}.

```ts
export interface UseSignInOptions {
    passwordReset?: PasswordResetOptions;
    onDone?: (signedIn: SignedIn) => void;
}
```

## useSignUp

```ts
export declare function useSignUp(options?: UseSignUpOptions): UseSignUp;
```

## UseSignUp

Headless sign-up: the flow state + the actions each step calls.

```ts
export interface UseSignUp {
    step: SignUpStep;
    email: string;
    error: string | null;
    errorCode: string | null;
    submitting: boolean;
    loginMethod: LoginMethod;
    loginMethods: LoginMethod[];
    selectLoginMethod: (method: LoginMethod) => void;
    delivery: {
        maskedIdentifier: string;
    } | null;
    codeResent: boolean;
    signUp: (input: SignUpInput) => Promise<void>;
    verify: (code: string) => Promise<void>;
    resend: () => Promise<void>;
    reset: () => void;
}
```

## UseSignUpOptions

Options for \{@link useSignUp}.

```ts
export interface UseSignUpOptions {
    autoSignIn?: boolean;
    onDone?: () => void;
}
```

## useSocialAuth

Build the social-login actions from discovery + the session. The SocialAuthClient adopts issued tokens
into the session (same lane as SRP/passwordless), verifies state/nonce, and exchanges the code with PKCE.

```ts
export declare function useSocialAuth(options?: UseSocialAuthOptions): UseSocialAuth;
```

## UseSocialAuth

Headless social auth: the enabled providers + the redirect-flow actions built from discovery.

```ts
export interface UseSocialAuth {
    config: DiscoveryConfig | null;
    loading: boolean;
    error: string | null;
    signInWithProvider: (provider: string) => Promise<void>;
    signInWithPopup: (provider: string, popup: PopupWindow, options?: {
        prompt?: 'login';
    }) => Promise<void>;
    handleRedirectCallback: (currentUrl?: string) => Promise<void>;
}
```

## UseSocialAuthOptions

Options for \{@link useSocialAuth}.

```ts
export interface UseSocialAuthOptions {
    discovery?: DiscoveryConfig | null;
    fetch?: typeof fetch;
    redirect?: (url: string) => void;
    store?: OAuthTransactionStore;
}
```

## useSocialCallback

Hear (and by default complete) the provider's return trip for this deployment through the shared callback
coordinator: concurrent and remounted callers share one completion, and only a callback started for this
deployment's client is ever delivered here.

```ts
export declare function useSocialCallback(options?: UseSocialCallbackOptions): UseSocialCallback;
```

## UseSocialCallback

The provider return trip as this deployment's widgets see it.

```ts
export interface UseSocialCallback {
    result: SocialRedirectResult | null;
}
```

## UseSocialCallbackOptions

Options for \{@link useSocialCallback}.

```ts
export interface UseSocialCallbackOptions {
    handleSocialRedirect?: boolean;
    discovery?: DiscoveryConfig | null;
    onSignedIn?: (signedIn: SignedIn) => void;
    onSocialError?: (error: SocialError) => void;
    redirect?: (url: string) => void;
}
```

## useUser

The signed-in user's claims (D27: userId=custom:sl_user_id, orgId=custom:orgId), or null.

```ts
export declare function useUser(): SaaSLayerUser | null;
```

## useUserServiceClient

An authed user-service client bound to the session (F3): set-password, connected-account lifecycle,
and MFA self-service against userServiceApiBase. Null when userServiceApiBase is not configured.

```ts
export declare function useUserServiceClient(): UserServiceClient | null;
```

## useVirtualRouter

Thin hook over the pure state machine.

```ts
export declare function useVirtualRouter(initial: string): VirtualRouter;
```

## ViewAsControl

"View as user" trigger: enter a member's suid and view as them inside the org. Rendered only when the caller holds
the registered impersonation permission (`saaslayer:users:account:impersonate`) in that org — the tuple the server
re-checks — and is not already impersonating (nested impersonation is refused). Drop it into a \<UserButton> menu or
anywhere in the app.

```ts
export declare function ViewAsControl({ appearance, orgId, onImpersonating }: ViewAsControlProps): React.JSX.Element | null;
```

## ViewAsControlProps

```ts
export interface ViewAsControlProps {
    appearance?: Appearance;
    orgId?: string;
    onImpersonating?: (target: ImpersonationTarget) => void;
}
```

## VirtualRouter

```ts
export interface VirtualRouter {
    current: string;
    canGoBack: boolean;
    navigate: (page: string) => void;
    back: () => void;
    reset: (page: string) => void;
}
```

## VirtualRouterState

```ts
export interface VirtualRouterState {
    stack: string[];
}
```
