Get notified when someone signs up
You launched. Someone signs up at 11pm while you’re watching TV. You find out at 9am when you open your analytics dashboard.
Here’s how to know at 11pm instead.
The simplest version
One line, after the user is created:
import fyi from "trigger.fyi"
async function createUser(data) {
const user = await db.users.create(data)
fyi("New signup", { body: user.email })
return user
}That’s it. TRIGGER_FYI_SECRET_KEY in your environment, one fyi() call, and your phone tells you every time someone signs up.
With metadata
The second argument is metadata — it travels with the notification and is filterable in the feed:
fyi("New signup", {
body: user.email,
plan: user.plan, // filter by plan
country: user.country, // filter by country
source: referral.source // filter by acquisition source
})Open the feed and filter by plan: pro to see only pro signups. Or source: twitter to see signups from a campaign.
In an API route
After the response is sent — the user’s request should never wait for the notification:
// Next.js App Router
export async function POST(req) {
const user = await createUser(await req.json())
const response = NextResponse.json(user)
// Fires after response is returned
waitUntil(fyi("New signup", { body: user.email, plan: user.plan }))
return response
}
// Express
app.post("/signup", async (req, res) => {
const user = await createUser(req.body)
res.json(user)
fyi("New signup", { body: user.email })
})fyi() never throws, so there’s no need for try/catch around it.
With better-auth
import { betterAuth } from "better-auth"
import fyi from "trigger.fyi"
export const auth = betterAuth({
databaseHooks: {
user: {
create: {
after: async (user) => {
fyi("New signup", {
body: user.email,
provider: user.provider || "email"
})
}
}
}
}
})The after hook fires after the user is created and committed. No risk of notifying before the user exists.
With Supabase Auth webhooks
Supabase can send a webhook on user.created:
// Your webhook endpoint
export async function POST(req) {
const body = await req.json()
if (body.type !== "user.created") return new Response("OK")
const user = body.record
fyi("New signup", {
body: user.email,
provider: user.app_metadata?.provider
})
return new Response("OK")
}What to put in the notification
The first argument is the title (bold on lock screen). Second argument adds detail:
// Minimal
fyi("New signup")
// With email
fyi("New signup", { body: user.email })
// With plan and source
fyi("New signup · Pro", { body: user.email, source: utm.source })
// First user from a campaign
fyi("First signup from Product Hunt!", { body: user.email })Don’t over-engineer the message. The email is usually enough. You can always add more later when you know what context is useful.
The first real signup
There’s a difference between a test and the first real stranger who found you and signed up.
The test proves the pipe works. The real signup is the activation moment — when you know the product is doing something real in the world.
Set up the notification before you launch. You want to be watching when the first one comes in.
Setup
npx trigger.fyiGenerates a key, subscribes your device. In your environment:
TRIGGER_FYI_SECRET_KEY=your_key_here
The SDK reads it at call time, not import time. Works in any runtime.
Related: Payment received notifications · Backend push notifications · Push notifications from Next.js · What is trigger.fyi?