Sign inGet Started

Node.js SDK

Send email with Remix

Use Parcel Wing from Remix actions so email is sent server-side after forms submit.

Install the SDK

The official SDK is published as @parcelwing/node.

Terminal

npm install @parcelwing/node

Route action

Remix actions are a natural place to validate form data, perform database writes, and then send lifecycle email.

app/routes/invite.tsx

import { json, type ActionFunctionArgs } from "@remix-run/node";
import { ParcelWing, ParcelWingError } from "@parcelwing/node";
 
const parcelWing = new ParcelWing({ apiKey: process.env.PARCEL_WING_API_KEY! });
 
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
 
try {
const [message] = await parcelWing.emails.send({
from: "Acme <[email protected]>",
to: String(formData.get("email") ?? ""),
template_alias: "welcome_email",
template_params: { first_name: String(formData.get("firstName") ?? "friend") },
});
 
return json({ id: message?.id });
} catch (error) {
if (error instanceof ParcelWingError) {
return json({ code: error.code, requestId: error.requestId }, { status: error.status });
}
 
return json({ error: "Unexpected error" }, { status: 500 });
}
}

Production notes

  • Keep PARCEL_WING_API_KEY in 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.