Guides / Signups & Auth
You ship your Next.js app, users start signing up, and you have no idea it's happening unless you manually check your database. There's no buzz, no signal โ you find out 3 days later when you look at your dashboard.
Call logit.now() right after you persist the new user. You'll get a push notification the moment it happens.
npm install logit
Create lib/logit.ts:
import { init } from "logit";
export const logit = init({ token: process.env.LOGIT_API_KEY! });
// app/actions/auth.ts
"use server";
import { logit } from "@/lib/logit";
export async function signupAction(formData: FormData) {
const email = formData.get("email") as string;
// ... create user in your DB
await logit.now("signups", {
event: "New user signed up",
description: email,
icon: "๐ค",
notify: true,
tags: { source: "signup-form" },
metadata: { email },
});
}
// app/api/auth/signup/route.ts
import { NextResponse } from "next/server";
import { logit } from "@/lib/logit";
export async function POST(req: Request) {
const { email, plan } = await req.json() as { email: string; plan: string };
// ... create user
await logit.now("signups", {
event: "New user signed up",
description: `${email} joined on ${plan}`,
icon: "๐ค",
notify: true,
tags: { plan },
metadata: { email },
});
return NextResponse.json({ ok: true });
}
notify: true to receive a push notification immediately โ useful when you're heads-down building.source tag if you have multiple signup flows (landing page, referral, invite link) โ lets you filter in the dashboard later.LOGIT_API_KEY to .env.local and your production environment variables.Try LogIt free
7-day trial. No credit card required.