A one-click Deploy to Vercel template gets you a working Next.js 16 App Router project with a form, an API route, a React Email template, and live transactional email delivery — in under 90 seconds. No SaaS dashboards to manage, no copy-paste setup.
The starter exports one API route. POST { email, name } from anywhere — your form, a webhook handler, an LLM tool call — and Posthawk renders the React Email template and ships the message.
The same SDK call works in Node and Edge runtimes. Switch with a one-line export const runtime = 'edge'.
// app/api/welcome/route.ts
import { Posthawk } from 'posthawk';
import { WelcomeEmail } from '@/emails/welcome';
// Optional: pin this route to Vercel's Edge runtime.
// The Posthawk SDK works in both Node and Edge.
// export const runtime = 'edge';
const posthawk = new Posthawk(process.env.POSTHAWK_API_KEY!);
export async function POST(req: Request) {
const { email, name } = await req.json();
const { data, error } = await posthawk.emails.send({
from: process.env.POSTHAWK_FROM_EMAIL!,
to: email,
subject: `Welcome, ${name}!`,
react: <WelcomeEmail name={name} />,
});
if (error) return Response.json({ error }, { status: 400 });
return Response.json({ id: data.id });
}Vercel forks the posthawk-dev/nextjs-starter template into your GitHub account and walks you through a setup screen.
Vercel prompts for POSTHAWK_API_KEY and POSTHAWK_FROM_EMAIL. The setup screen links straight to where you create the key in your Posthawk dashboard.
Vercel deploys to your *.vercel.app subdomain. Open it, fill in the form, click send — a real email lands in the recipient inbox within ~5 seconds.
The SDK is fetch-based with zero Node-only dependencies. Export `runtime = "edge"` in any API route to opt in — no rewrite, no second package.
Pass a `react` prop to `posthawk.emails.send()` and the SDK renders the component to HTML server-side. The starter ships with a working WelcomeEmail.tsx.
Every Vercel preview gets its own working email endpoint with your env vars wired in. Test the welcome flow on a PR branch before merging.
The SDK unwraps every response into { data, error }. error.requestId lets you trace any failure across Posthawk's logs in one search.
Click the button, paste your API key, deploy. The starter handles the rest.
I use analytics cookies to understand how you use the site and improve your experience. Privacy Policy