Welcome email on Supabase Auth signup

Send a welcome email when a user signs up in Supabase Auth, using an Edge Function triggered by a Database Webhook.

Create a Database Webhook on auth.users (INSERT) pointing to an Edge Function that calls Publiq:

import { Publiq } from 'npm:publiq';

const publiq = new Publiq(Deno.env.get('PUBLIQ_API_KEY'));

Deno.serve(async (req) => {
  const { record } = await req.json(); // the new auth.users row
  await publiq.emails.send({
    from: 'you@yourdomain.com',
    to: record.email,
    templateKey: 'welcome-email',
    variables: { first_name: record.raw_user_meta_data?.name ?? 'there' },
  });
  return new Response('ok');
});

Set PUBLIQ_API_KEY in the function secrets: supabase secrets set PUBLIQ_API_KEY=pk_....

Best practices

  • Always call Publiq from the server — never expose the API key on the client.
  • Create the client instance once and reuse it across requests.
  • Prefer templateKey over inline HTML to keep content versioned.
  • Handle PubliqError (status/code); the SDK already retries transient errors with backoff.
  • Send from a verified domain — see Domains.

See also

Welcome email on Supabase Auth signup — Publiq Docs