Skip to main content
Send transactional emails from Vercel serverless functions using Lettr’s HTTP API. Vercel’s global edge network and fast cold starts make it perfect for email-triggered API routes and server actions. Using Cursor? Jump straight in using this prompt

Prerequisites

Before you begin, make sure you have:

API Key

Create an API key in the Lettr dashboard

Verified Domain

Add and verify your sending domain
You’ll also need:
  • Vercel account with a project deployed or ready to deploy
  • Next.js project (recommended) or a Node.js serverless function
  • Node.js 18.x or 20.x runtime

Quick Setup

1

Install the Lettr SDK

The SDK provides a clean interface for sending emails with full TypeScript support.
2

Add environment variables

Add your API key via the Vercel dashboard or CLI:
When prompted, paste your API key (starts with lttr_). Then add your from email:
For local development, create a .env.local file with the same variables. Vercel automatically loads .env.local in development mode.
3

Create an API route

Create a file at app/api/send/route.ts (App Router) or pages/api/send.ts (Pages Router) with the code examples below.
4

Deploy

Your email API route will be available at https://your-domain.vercel.app/api/send.
For Next.js 13+ projects using the App Router, create a file at app/api/send/route.ts:
The maxDuration export configures the maximum execution time for the function. Email sending typically completes in under 1 second, but setting a higher limit accounts for retries and network latency.

Next.js Pages Router

For Next.js projects using the Pages Router, create a file at pages/api/send.ts:

What’s Next

Advanced Guide

Learn about Server Actions, Edge Runtime, and advanced patterns

AWS Lambda

Deploy on AWS Lambda

Cloudflare Workers

Deploy on Cloudflare

API Reference

Complete API documentation