export const clientCode = `// This doesn't change when you add MiniMoth
const { error } = await supabase.auth.signInWithOtp({ phone })`

export const verifyConnectionCode = `import { createClient } from '@supabase/supabase-js'
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)

// 1. Send — this is what calls MiniMoth's hook
await supabase.auth.signInWithOtp({ phone: '+919876543210' })

// 2. Verify — the code the user received
await supabase.auth.verifyOtp({ phone: '+919876543210', token: '123456', type: 'sms' })`

Deliver Supabase Auth's phone OTPs over WhatsApp first, SMS fallback, for Indian numbers — at MiniMoth's rate, with zero changes to your application code.

## How it fits together

Supabase Auth already owns the entire OTP lifecycle — it generates the code, verifies it, and issues the session. MiniMoth becomes the delivery backend Supabase calls out to via its <a href="https://supabase.com/docs/guides/auth/auth-hooks/send-sms-hook" target="_blank" rel="noopener noreferrer">Send SMS Hook</a>. Your own application code doesn't change:

<CodeBlock code={clientCode} lang="typescript" />

<div className="bg-white/5 border border-white/10 rounded-lg px-4 py-3 text-xs text-ink/50 leading-relaxed mt-3">
  MiniMoth never sees the Supabase session or the verification step — only the outbound SMS-hook call Supabase makes when it needs an OTP delivered. This is a delivery-backend integration, not an auth provider swap. One consequence: this integration never returns a MiniMoth <a href="/docs/identity" className="text-saffron hover:underline">identity_id</a> — Supabase already owns that user's identity in <code className="font-mono">auth.users</code>, so use its id instead.
</div>

## Setup

Wire up test mode first — it confirms the connection without sending a real message or touching your balance.

1. **MiniMoth dashboard** — open your project, find the Supabase Hook card, and click `Enable Supabase Hook`. Copy the `Test` Hook URL and Secret.

   <img
     src="/docs-supabase-hook-card.png"
     alt="The Supabase Hook card in the MiniMoth dashboard, before it's enabled, with an Enable Supabase Hook button"
     className="w-full max-w-2xl rounded-lg border border-white/10 my-3"
     width="1402"
     height="470"
   />

2. **Supabase dashboard** — go to `Authentication → Hooks → Send SMS hook`, choose `HTTPS`, paste the test URL and secret, and save.

   <img
     src="/docs-supabase-auth-hooks-page.png"
     alt="Supabase's Auth Hooks dashboard page, with the Add a new hook menu open showing the Send SMS hook option"
     className="w-full max-w-2xl rounded-lg border border-white/10 my-3"
     width="2402"
     height="804"
   />

3. **Verify the connection** — trigger `signInWithOtp()` from your app, then check <a href="https://supabase.com/dashboard" target="_blank" rel="noopener noreferrer">Supabase's own Auth logs</a> for a successful call. Test mode sends no real message, so this is the only way to confirm the hook is wired correctly — MiniMoth's own Playground can't substitute for it here, since Supabase owns the request.

   No app to test from yet? Paste this into a scratch file:

   <CodeBlock code={verifyConnectionCode} lang="javascript" />

4. **Go live** — repeat steps 1–2 with the `Live` Hook URL and Secret. This is also the only way to see a real OTP actually delivered, since test mode by design never sends one.

<div className="mt-6">
  <Callout variant="accent">
    <p className="font-medium mb-1">Billing</p>
    <p className="text-ink/60">
      Real OTPs sent via the live hook are billed to your wallet balance at send time, at the same default rate (₹0.35) as calling the API directly. Test-mode calls cost nothing and consume no credits.
    </p>
  </Callout>
</div>

---

Full documentation index: https://minimoth.dev/llms.txt
