Node.js SDK
Send email with Nuxt
Use Parcel Wing from Nuxt server API routes and call them from Vue components.
Install the SDK
The official SDK is published as @parcelwing/node.
Terminal
npm install @parcelwing/node
Server API route
Create a Nuxt server route that owns the Parcel Wing client and keeps your API key away from the browser.
server/api/send-welcome.post.ts
import { ParcelWing } from "@parcelwing/node";const parcelWing = new ParcelWing({ apiKey: process.env.PARCEL_WING_API_KEY! });export default defineEventHandler(async (event) => {const body = await readBody<{ email: string; firstName?: string }>(event);const [message] = await parcelWing.emails.send({from: "Acme <[email protected]>",to: body.email,template_alias: "welcome_email",template_params: { first_name: body.firstName ?? "friend" },});return { id: message?.id };});
Production notes
- Keep
PARCEL_WING_API_KEYin server-only environment variables. - Validate recipient addresses and public form input before sending.
- Use saved templates for onboarding, invites, receipts, and other repeatable lifecycle email.