Docs/Reference

API map

Find the package entry points, server surfaces, client flows, React exports, and supporting modules.

Auth Dance publishes a small set of explicit entry points. Use this map to jump from a concept to the module that owns it.

Package entry points

Import Main exports
auth-dance createAuthDance, choreography constructors, AuthDanceStorage, errors, types, API and app constructors
auth-dance/client AuthDanceClient, client choreography, stores, flow definitions and client errors
auth-dance/react Provider, flow provider, prompt switch, hooks, and re-exported client types
auth-dance/components/* email, otp, password, totp, webauthn
auth-dance/providers/* memory, deno, cloudflare

Server instance

createAuthDance(options) returns:

  • api — direct state-machine access.
  • app — the Hono application.
  • fetch — a standard request handler with the API and address rate-limit bindings attached.
  • generateOpenAPISchema() — the OpenAPI document generator.

Use createAuthDanceApi and createAuthDanceApp when the state machine and HTTP layer need to be constructed independently.

Client choreography

An AuthDanceClientChoreography exposes:

  • State: flow, name, prompt, current, choices, selected, trail, expired, and done.
  • Movement: choose, submitPrompt, sendPrompt, confirm, prev, restart, and abandon.
  • Persistence: snapshot() and the optional choreography store passed when a flow starts.

The client itself exposes the nine flow starters, credential restore and refresh behavior, session listing and revocation, and sign-out.

Errors

Server errors extend AuthDanceError and carry stable codes through the Errors registry. The client rethrows mapped server failures with those classes. Protocol or response-shape failures use AuthDanceClientError subclasses.

Handle specific exported classes where recovery differs. Render a general retry path for unknown failures and keep diagnostic details in application logs.

Source reference

The adjacent library source is the authority for this documentation version. Each public export has JSDoc in the source module, and colocated tests show accepted and refused states.