Docs
Frameworks

Next.js

Send from a Route Handler or Server Action.

npm install resend

Add to .env.local:

API_KEY=pw_xxxxxxxxx
RESEND_BASE_URL=https://postwaves.online
import { Resend } from 'resend';

const client = new Resend(process.env.API_KEY);

export async function POST(req: Request) {
  const { email, name } = await req.json();
  const { data, error } = await client.emails.send({
    from: 'Acme <hello@yourdomain.com>',
    to: [email],
    subject: `Welcome, ${name}`,
    html: `<p>Hi ${name}, thanks for signing up!</p>`,
  });
  if (error) return Response.json({ error }, { status: 400 });
  return Response.json(data);
}
Was this page helpful?Send feedback