React SDK
Checked example
This example is included from typechecked source. Complete the integration guide for your deployment and framework.
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
export declare function AcceptInvitation({ token, appearance, onAccepted, signedOut }: AcceptInvitationProps): React.JSX.Element;AcceptInvitationProps
export interface AcceptInvitationProps {
token: string;
appearance?: Appearance;
onAccepted?: (result: {
orgId: string;
grants: InvitationGrant[];
userId: string;
}) => void;
signedOut?: ReactNode;
}AccessRequests
export declare function AccessRequests({ userId: userIdProp, client: clientProp, appearance: appearanceProp, onError }: AccessRequestsProps): React.JSX.Element;AccessRequestsProps
export interface AccessRequestsProps {
userId?: string;
client?: PermissionsClient;
appearance?: Appearance;
onError?: (err: Error) => void;
}AccountPortal
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>.
export declare const AccountPortalPage: {
(props: { id: string; label: string; children?: ReactNode; }): ReactNode | Promise<ReactNode>;
"partName": string;
"propTypes": any;
"displayName": string | undefined;
};AccountPortalProps
export interface AccountPortalProps {
appearance?: Appearance;
mode?: 'page' | 'modal';
sections?: AccountPortalSection[];
children?: ReactNode;
}AccountPortalSection
The built-in, backed sections.
export type AccountPortalSection = 'profile' | 'organizations' | 'apiKeys' | 'passkeys';ApiKeys
export declare function ApiKeys({ client: clientProp, appearance: appearanceProp, onError }: ApiKeysProps): React.JSX.Element;ApiKeysProps
export interface ApiKeysProps {
client?: PermissionsClient;
appearance?: Appearance;
onError?: (err: Error) => void;
}Appearance
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.
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.
export type AppearanceVar = 'colorPrimary' | 'colorText' | 'colorBackground' | 'colorDanger' | 'colorBorder' | 'borderRadius' | 'fontFamily' | 'spacingUnit' | 'colorTextMuted' | 'colorSurface' | 'colorBorderSubtle' | 'colorFocus' | 'colorSuccess' | 'colorWarning';AuditLog
export declare function AuditLog({ scope: scopeProp, client: clientProp, appearance: appearanceProp, pageSize, onError }: AuditLogProps): React.JSX.Element;AuditLogProps
export interface AuditLogProps {
scope?: string;
client?: PermissionsClient;
appearance?: Appearance;
pageSize?: number;
onError?: (err: Error) => void;
}AuthorizeDebugger
export declare function AuthorizeDebugger({ client: clientProp, action: actionProp, resource: resourceProp, product, service, appearance: appearanceProp }: AuthorizeDebuggerProps): React.JSX.Element;AuthorizeDebuggerProps
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).
export declare function back(state: VirtualRouterState): VirtualRouterState;Boundaries
export declare function Boundaries({ client: clientProp, appearance: appearanceProp, onError }: BoundariesProps): React.JSX.Element;BoundariesProps
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
({ allowed, loading, reason }) => ... to disable + explain instead of hide.
export declare function Can({ children, fallback, denied, ...spec }: CanProps): React.JSX.Element;CanFn
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
export interface CanProps extends GateSpec {
children: GateChildren;
fallback?: ReactNode;
denied?: ReactNode;
}clearScope
Remove the persisted scope (best-effort). Never throws.
export declare function clearScope(): void;collectParts
Collect, in source order, the props of every child that is the given part. Non-matching children ignored.
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).
export declare function completeCheck(c: PermissionCheckInput, fallback?: DecisionTargetDefaults): PermissionCheck;CreateOrganization
export declare function CreateOrganization({ client: clientProp, appearance: appearanceProp, onCreated, title }: CreateOrganizationProps): React.JSX.Element;CreateOrganizationProps
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.
export declare function createPart<P>(partName: string): PartComponent<P>;createScopeStore
A scope store over options.session.
export declare function createScopeStore(options: ScopeStoreOptions): ScopeStore;current
export declare function current(state: VirtualRouterState): string;DecisionTargetDefaults
The provider-level default decision target (SaaSLayerConfig product/service).
export interface DecisionTargetDefaults {
product?: string;
service?: string;
}decodeJwtPayload
Decode a JWT payload (base64url) without verifying — returns {} on any error.
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.
export declare function defaultScope(user: SaaSLayerUser | null): Scope;DeploymentDiscovery
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
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
export declare function deploymentDiscoveryUrl(target: DiscoveryTarget): string;DISCOVERY_CONTRACT_VERSION
export declare const DISCOVERY_CONTRACT_VERSION: 2;DiscoveryInstances
export interface DiscoveryInstances {
'user-service'?: string;
'permissions-service'?: string;
}DiscoveryTarget
export type DiscoveryTarget = {
url: string;
refreshSeconds?: number;
} | {
apiBase: string;
deploymentId: string;
instances?: DiscoveryInstances;
};EffectivePermissions
export declare function EffectivePermissions({ userId: userIdProp, principalType, scope: scopeProp, client: clientProp, appearance: appearanceProp, onError }: EffectivePermissionsProps): React.JSX.Element;EffectivePermissionsProps
export interface EffectivePermissionsProps {
userId?: string;
principalType?: string;
scope?: string;
client?: PermissionsClient;
appearance?: Appearance;
onError?: (err: Error) => void;
}ELEMENT_IDS
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
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.
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-<id> 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.
export declare function elementProps(appearance: Appearance | undefined, id: string, extraClass?: string): { className: string; style?: CSSProperties; "data-sl-el": string; part?: string; };fetchDeploymentDiscovery
export declare function fetchDeploymentDiscovery(target: DiscoveryTarget, options?: { fetch?: typeof fetch; }): Promise<DeploymentDiscovery>;ForgotPassword
export declare function ForgotPassword({ appearance, onDone, onBackToSignIn, phoneLogin: ownPhone, passwordReset }: ForgotPasswordProps): React.JSX.Element;ForgotPasswordProps
export interface ForgotPasswordProps {
appearance?: Appearance;
onDone?: () => void;
onBackToSignIn?: () => void;
phoneLogin?: PhoneLoginOptions;
passwordReset?: PasswordResetOptions;
}GateSpec
Props a gate accepts to describe what it requires.
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.
export interface GateState {
allowed: boolean | undefined;
loading: boolean;
error: Error | null;
reason: string | null;
}Groups
export declare function Groups({ workspaceId: workspaceIdProp, client: clientProp, appearance: appearanceProp, onError }: GroupsProps): React.JSX.Element;GroupsProps
export interface GroupsProps {
workspaceId?: string;
client?: PermissionsClient;
appearance?: Appearance;
onError?: (err: Error) => void;
}IMPERSONATION_PERMISSION
The registered impersonation permission (product:service:type:action).
export declare const IMPERSONATION_PERMISSION: "saaslayer:users:account:impersonate";ImpersonationBanner
Always-visible while impersonating: "Viewing as X" + a Stop action. Renders nothing otherwise.
export declare function ImpersonationBanner({ appearance, children }: ImpersonationBannerProps): React.JSX.Element | null;ImpersonationBannerProps
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/<suid>) or on login accounts in general.
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.
export interface ImpersonationTarget {
targetSuid: string;
orgId: string;
mode?: ImpersonationMode;
}initRouter
export declare function initRouter(initial: string): VirtualRouterState;isKnownElementId
True when an id is part of the frozen public registry.
export declare function isKnownElementId(id: string): boolean;loadScope
Read the persisted active scope, or null if absent/unavailable/corrupt. Never throws.
export declare function loadScope(): Scope | null;mergeAppearance
Merge a per-widget appearance onto the provider-level default (widget wins per field).
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.
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.
export declare function MfaEnrollmentGate({ appearance, children }: MfaEnrollmentGateProps): React.JSX.Element | null;MfaEnrollmentGateProps
export interface MfaEnrollmentGateProps {
appearance?: Appearance;
children: ReactNode;
}MfaEnrollmentProps
export interface MfaEnrollmentProps {
appearance?: Appearance;
onEnrolled?: () => void;
}MfaState
The resolved MFA posture for the current user.
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).
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).
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).
export declare function normalizePermission(input: PermissionInput): PermissionCheckInput;OrganizationInvitations
export declare function OrganizationInvitations({ orgId: orgIdProp, appearance: appearanceProp }: OrganizationInvitationsProps): React.JSX.Element;OrganizationInvitationsProps
export interface OrganizationInvitationsProps {
orgId?: string;
appearance?: Appearance;
}OrganizationProfile
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>.
export declare const OrganizationProfilePage: {
(props: { label: string; children?: ReactNode; }): ReactNode | Promise<ReactNode>;
"partName": string;
"propTypes": any;
"displayName": string | undefined;
};OrganizationSwitcher
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").
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.
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.
export interface PartComponent<P> extends FunctionComponent<P> {
partName: string;
}Passkeys
export declare function Passkeys({ discovery, appearance: appearanceProp, onError }: PasskeysProps): React.JSX.Element;PasskeysProps
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.
export interface PasswordResetOptions {
emailDelivery?: 'code' | 'link';
handleRedirect?: boolean;
}PermissionBatcher
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.
export type PermissionCheckInput = Omit<PermissionCheck, 'product' | 'service'> & {
product?: string;
service?: string;
};PermissionInput
One permission, compact-string or explicit-object form.
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.
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>.
export declare function Protect({ children, fallback, ...spec }: ProtectProps): React.JSX.Element;ProtectProps
export interface ProtectProps extends GateSpec {
children: ReactNode;
fallback?: ReactNode;
}providerConfigFromDiscovery
The <SaaSLayerProvider> config a discovery document describes, plus the app's own defaults.
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).
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.
export declare function resolveGate(spec: GateSpec, defaults?: DecisionTargetDefaults): { checks: PermissionCheck[]; match: "all" | "any"; };RoleEditor
export declare function RoleEditor({ orgId: orgIdProp, client: clientProp, appearance: appearanceProp, isProtected, onError }: RoleEditorProps): React.JSX.Element;RoleEditorProps
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).
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.
export type SaaSLayerConnector = AccountConnector & MfaConnector;SaaSLayerProvider
Wrap the app once. Owns the session, connector, appearance, and active scope for its subtree.
export declare function SaaSLayerProvider({ config, appearance, session, connector, discovery, secondaryConnector, phoneLogin, storage, initialScope, scopeStore, batchPermissions, children }: SaaSLayerProviderProps): React.JSX.Element;SaaSLayerProviderProps
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).
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.
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.
export interface ScopePreference {
load(viewer: string | null): Scope | null;
save(viewer: string | null, scope: Scope): void;
}ScopeState
export interface ScopeState {
scope: Scope;
organizations: OrgRef[];
projects: OrgRef[];
loading: boolean;
error: Error | null;
listed: boolean;
preparing: boolean;
timedOut: boolean;
generation: number;
}ScopeStore
export interface ScopeStore {
getState(): ScopeState;
subscribe(listener: () => void): () => void;
select(next: Scope): Promise<void>;
reload(): void;
}ScopeStoreOptions
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.
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.
export declare function SignIn(props: SignInProps): React.JSX.Element;SignInProps
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).
export type SignInStep = 'password' | 'mfa' | 'newPassword' | 'resetPassword' | 'resetLinkSent' | 'resetSignIn' | 'magicLinkSent' | 'done';SignUp
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.
export interface SignUpInput {
email?: string;
phoneNumber?: string;
password: string;
orgName?: string;
}SignUpProps
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.
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.
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).
export declare function SocialButtons({ appearance, labelPrefix, discovery, fetch, redirect, store, onError, mode, onSocialError, openPopup }: SocialButtonsProps): React.JSX.Element | null;SocialButtonsProps
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.
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.
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).
export declare function SsoFactors({ client: clientProp, required, appName, account, onSignInAgain, onChange, credentials, appearance }: SsoFactorsProps): React.JSX.Element;SsoFactorsProps
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.
export declare function SsoSettings({ connectionId, client: clientProp, permissionsClient: permissionsProp, mode, setupUrl, signInUrl, onSessionEnded, onError, appearance }: SsoSettingsProps): React.JSX.Element;SsoSettingsProps
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.
export declare function SsoSetup({ userServiceApiBase, fetch: fetchImpl, signInUrl, appearance }: SsoSetupProps): React.JSX.Element;SsoSetupProps
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.
export declare function SsoStepUp({ client: clientProp, passkeys, credentials, onVerified, onCancel, appearance }: SsoStepUpProps): React.JSX.Element;SsoStepUpProps
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
export declare function StepUpChallenge({ appearance, onSubmitCode, onFido2, onVerified }: StepUpChallengeProps): React.JSX.Element;StepUpChallengeProps
export interface StepUpChallengeProps {
appearance?: Appearance;
onSubmitCode?: (code: string) => Promise<void>;
onFido2?: () => Promise<void>;
onVerified?: () => void;
}useAuth
export declare function useAuth(): UseAuth;UseAuth
Reactive auth state + actions.
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.
export declare function useCan(): CanFn;useConnector
The account/MFA connector for self-service ops (signUp/forgotPassword/TOTP) — used by the auth widgets.
export declare function useConnector(): SaaSLayerConnector;useDiscovery
Fetch + cache the public discovery descriptor for the configured userServiceApiBase (E1), or the provider's injected one.
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.
export declare function useGate(checks: PermissionCheck[], match: "all" | "any"): GateState;useImpersonation
export declare function useImpersonation(): UseImpersonation;UseImpersonation
Reactive impersonation state + actions. The effective identity comes from useUser (the as_* claims).
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().
export declare function useInvitations(orgId: string | null): UseInvitations;UseInvitations
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.
export declare function useMfa(): MfaState;useOrganization
The active org + project resolved from the current scope against the caller's own lists.
export declare function useOrganization(): UseOrganization;UseOrganization
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().
export declare function useOrganizationList(): UseOrganizationList;UseOrganizationList
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.
export declare function usePermission(check: PermissionCheckInput): UsePermission;UsePermission
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).
export declare function usePermissionBatcher(): PermissionBatcher | null;UserButton
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
export interface UserButtonProps {
appearance?: Appearance;
children?: ReactNode;
}UserGrants
export declare function UserGrants({ granteeId: granteeIdProp, client: clientProp, appearance: appearanceProp, onError }: UserGrantsProps): React.JSX.Element;UserGrantsProps
export interface UserGrantsProps {
granteeId?: string;
client?: PermissionsClient;
appearance?: Appearance;
onError?: (err: Error) => void;
}UserProfile
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>.
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.
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).
export declare function useScope(): { scope: Scope; setScope: (next: Scope) => Promise<void>; };useSignIn
export declare function useSignIn(options?: UseSignInOptions): UseSignIn;UseSignIn
Headless password sign-in: the flow state + the actions each step calls.
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}.
export interface UseSignInOptions {
passwordReset?: PasswordResetOptions;
onDone?: (signedIn: SignedIn) => void;
}useSignUp
export declare function useSignUp(options?: UseSignUpOptions): UseSignUp;UseSignUp
Headless sign-up: the flow state + the actions each step calls.
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}.
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.
export declare function useSocialAuth(options?: UseSocialAuthOptions): UseSocialAuth;UseSocialAuth
Headless social auth: the enabled providers + the redirect-flow actions built from discovery.
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}.
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.
export declare function useSocialCallback(options?: UseSocialCallbackOptions): UseSocialCallback;UseSocialCallback
The provider return trip as this deployment's widgets see it.
export interface UseSocialCallback {
result: SocialRedirectResult | null;
}UseSocialCallbackOptions
Options for {@link useSocialCallback}.
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.
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.
export declare function useUserServiceClient(): UserServiceClient | null;useVirtualRouter
Thin hook over the pure state machine.
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.
export declare function ViewAsControl({ appearance, orgId, onImpersonating }: ViewAsControlProps): React.JSX.Element | null;ViewAsControlProps
export interface ViewAsControlProps {
appearance?: Appearance;
orgId?: string;
onImpersonating?: (target: ImpersonationTarget) => void;
}VirtualRouter
export interface VirtualRouter {
current: string;
canGoBack: boolean;
navigate: (page: string) => void;
back: () => void;
reset: (page: string) => void;
}VirtualRouterState
export interface VirtualRouterState {
stack: string[];
}