Guides / Signups & Auth
Supabase Auth handles the signup flow, but there's no built-in way to get notified when it happens. You can use Supabase Edge Functions, webhooks, or server-side auth callbacks.
If you're validating sessions server-side, call LogIt right after the user record is confirmed:
// app/api/auth/callback/route.ts
import { createClient } from "@supabase/supabase-js";
import { logit } from "@/lib/logit";
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const code = searchParams.get("code");
if (code) {
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SERVICE_KEY!
);
const { data: { user } } = await supabase.auth.exchangeCodeForSession(code);
if (user?.created_at) {
const isNew = new Date(user.created_at) > new Date(Date.now() - 5000);
if (isNew) {
await logit.now("signups", {
event: "New Supabase user signed up",
description: user.email ?? "Unknown",
icon: "๐ค",
notify: true,
tags: { provider: user.app_metadata?.provider ?? "email" },
metadata: { userId: user.id, email: user.email },
});
}
}
}
return Response.redirect(new URL("/dashboard", request.url));
}
Create a Supabase Edge Function triggered by the auth.users insert event:
// supabase/functions/on-user-signup/index.ts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
serve(async (req) => {
const payload = await req.json();
const user = payload.record;
await fetch("https://logit.now/api/v1/events", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${Deno.env.get("LOGIT_API_KEY")}`,
},
body: JSON.stringify({
channel: "signups",
event: "New Supabase user",
description: user.email,
icon: "๐ค",
notify: true,
metadata: { userId: user.id, provider: user.raw_app_meta_data?.provider },
}),
});
return new Response("ok");
});
Then configure the webhook in your Supabase dashboard under Database โ Webhooks, pointing to this function on the auth.users table INSERT event.
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
SUPABASE_SERVICE_KEY=your-service-key
Try LogIt free
7-day trial. No credit card required.