Skip to content
emailkit
Esc
navigateopen⌘Jpreview
On this page

Quickstart

Install emailkit and send your first email in a few minutes.

This guide uses Resend because it’s the fastest to set up. Everything you write here works the same with any other provider.

Install emailkit

npm install emailkit
pnpm add emailkit
yarn add emailkit
bun add emailkit

emailkit needs Node.js 20.19 or newer.

Add your API key

RESEND_API_KEY="re_..."

Create the client

import { EmailKit, ResendDriver } from "emailkit";

export const emailkit = EmailKit({
  emailDrivers: [
    ResendDriver({
      apiKey: process.env.RESEND_API_KEY!,
    }),
  ],
});

Send an email

import { emailkit } from "./emailkit";

const result = await emailkit.sendEmail({
  from: { email: "hello@example.com", name: "Acme" },
  to: { email: "ada@example.com" },
  subject: "Hello from emailkit",
  text: "One API. Any email provider.",
  html: "<strong>One API.</strong> Any email provider.",
});

console.log(result.messageId, result.provider);

Done. That’s sending.

Add receiving

Receiving takes two things: hooks for the events you care about, and one public route.

export const emailkit = EmailKit({
  emailDrivers: [
    ResendDriver({
      apiKey: process.env.RESEND_API_KEY!,
      webhookSecret: process.env.RESEND_WEBHOOK_SECRET!,
    }),
  ],
  hooks: {
    email: {
      onInbound: async (email) => {
        await prisma.inboundEmail.create({
          data: {
            messageId: email.messageId,
            from: email.from.email,
            subject: email.subject,
            text: email.text,
          },
        });
      },
    },
  },
});

For Next.js, the route is one line:

import { createNextEmailKitHandler } from "emailkit/nextjs";
import { emailkit } from "@/src/emailkit";

export const { GET, POST } = createNextEmailKitHandler(emailkit);

This is the single-driver shortcut. Once you add more providers, switch to one dynamic route that serves them all — the Receiving guide shows it.

Point your provider’s webhook to https://your-app.com/api/email. emailkit verifies every request and hands your hooks the same clean format, no matter the provider.

Where to go next

Last updated on July 24, 2026

Was this page helpful?