Supabase Integration
Use WordAuth as a passwordless login mechanism with Supabase Auth.
WordAuth replaces magic-link emails with human-readable word pairs delivered by SMS or email. The Supabase session is established using the standard verifyOtp flow, so it works with any Supabase project without extra configuration.
How the flow works
- 1User submits their email address.
- 2Your server route calls WordAuth /v1/generate with the user's email, which generates and delivers an OTP.
- 3Your UI prompts the user to enter the word pair.
- 4Your server route calls WordAuth /v1/validate to verify the code. If valid, it uses the Supabase admin client to generate a magic-link token_hash for that email.
- 5The client calls supabase.auth.verifyOtp({ token_hash, type: "magiclink" }) to establish the Supabase session.
Prerequisites
- •A WordAuth API key (
WORDAUTH_API_KEY) — server-side only - •A Supabase service role key (
SUPABASE_SERVICE_ROLE_KEY) — server-side only, never expose to the client - •
npm install wordauth @supabase/supabase-js
Route 1 — Send the word pair
Create a server route that generates a WordAuth OTP and delivers it. The example below uses Next.js App Router, but the logic is the same in any framework.
app/api/auth/send-otp/route.ts
Route 2 — Verify and create a session
Validate the word pair with WordAuth, then use the Supabase admin client to generate a magic-link token_hash for the email. Return that hash to the client so it can sign in.
app/api/auth/verify-otp/route.ts
Client — Establish the Supabase session
Use the token_hash returned from your verify route to sign the user in via the standard Supabase client.
Full React example
OAuth providers
WordAuth works alongside standard Supabase OAuth. Users who prefer Google or GitHub can sign in via supabase.auth.signInWithOAuth — no changes needed.