Docs/Build the flow

Connect storage and delivery

Select memory, Deno, or Cloudflare providers and understand the three storage responsibilities.

AuthDanceStorage composes three provider interfaces: identity records, key-value state, and rate-limit counters. Delivery channels are configured beside storage because components address them by name.

Memory

The memory module exports each provider separately and a convenience constructor.

import { createAuthDanceMemoryStorage } from "auth-dance/providers/memory";

const storage = createAuthDanceMemoryStorage();

Memory storage is useful for tests, examples, and short-lived local processes. It is not persistent.

Deno KV

The Deno module maps identity and key-value responsibilities onto one Deno.Kv. It does not include a separate rate-limiter provider.

import { createAuthDanceDenoStorage } from "auth-dance/providers/deno";

const kv = await Deno.openKv();
const storage = createAuthDanceDenoStorage(kv);

Cloudflare

The Cloudflare convenience constructor combines D1 for identities, KV for short-lived state, and a Durable Object namespace for rate limiting.

import { createAuthDanceCloudflareStorage } from "auth-dance/providers/cloudflare";

const storage = createAuthDanceCloudflareStorage(
  env.AUTH_KV,
  env.AUTH_DB,
  env.AUTH_RATE_LIMITER,
);

The same module exports CloudflareSendMailAuthDanceChannel for Cloudflare's Send Email binding and RateLimiterDurableObject for the required Durable Object implementation.

Supply a custom provider

Implement AuthDanceIdentityProvider, AuthDanceKvProvider, or AuthDanceRateLimiterProvider and compose them with new AuthDanceStorage(...). This keeps deployment-specific persistence outside the choreography and components.

Channels implement AuthDanceChannel. A channel receives the message returned by a sendable component and delivers it to the address stored on the identity.