Clerk for sign-in, Notix for everything else you send.
Clerk manages sign-in and its own authentication emails. The rest of your app's mail, receipts, alerts, onboarding, comes from your code. This page reads the signed-in user's address from Clerk on the server and sends with notix-js.
Send an email from Clerk.
import { currentUser } from "@clerk/nextjs/server";
import { Notix } from "notix-js";
const notix = new Notix(process.env.NOTIX_API_KEY!);
export async function POST() {
const user = await currentUser();
const to = user?.primaryEmailAddress?.emailAddress;
if (!user || !to) return new Response("Unauthorized", { status: 401 });
const { data, error } = await notix.emails.send(
{ from: "Acme <hello@acme.com>", to, subject: "Welcome to Acme", html: "<p>Glad you are here.</p>" },
{ idempotencyKey: `welcome-${user.id}` },
);
if (error) return Response.json({ error }, { status: 502 });
return Response.json({ id: data?.emailId });
}
The from address must be on a domain you have verified in Notix. Step by step: the Next.js quickstart and the longer guide to sending email from Next.js.
One API key, kept on the server.
Create an API key on the API keys page of the Notix console and store it as NOTIX_API_KEY in .env.local and your host's environment. Never give it the NEXT_PUBLIC_ prefix: variables with that prefix are built into the browser bundle, and anyone who opens the site can read them.
A Send only key is enough for code that only sends: if it leaks, it cannot read your contacts or delete a domain.
NOTIX_API_KEY=notix_xxxxxxxxxxxx
NOTIX_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx
Questions, answered.
Does Notix replace Clerk's own emails?
Why an idempotency key on a welcome email?
Why is my send refused with a from-address error?
Send your first email in five minutes.
Verify a domain, copy an API key, make one call. The free plan does not ask for a card.