All guides
Send Email from Nuxt
Send emails from Nuxt server routes and API endpoints
1. Install the SDK
npm install sendpigeon2. Set your API key
Add your SendPigeon API key to your environment variables:
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
sendpigeonApiKey: process.env.SENDPIGEON_API_KEY,
},
})Get your API key from the dashboard.
3. Send your first email
// server/api/contact.post.ts
import { SendPigeon } from "sendpigeon";
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig();
const client = new SendPigeon(config.sendpigeonApiKey);
const { email, name } = await readBody(event);
await client.emails.send({
from: "hello@yourdomain.com",
to: email,
subject: `Thanks for reaching out, ${name}!`,
html: `<h1>We got your message</h1><p>We'll get back to you soon.</p>`,
});
return { success: true };
});Features
- Works with Nuxt 3 server routes
- Nitro server engine
- Auto-imports and TypeScript
Ready to send emails?
Get started with 1,000 free emails per month.
Start for free