Send emails with Next.js

Resend is transforming email for developers. Simple interface, easy integrations, handy templates. What else could we ask for.
Guillermo Rauch

Guillermo Rauch

Creator of Next.js

Built for React applications

Integrate with react.email, our collection of high-quality, unstyled components for creating beautiful emails using TypeScript. Forget about inconsistencies with different email clients.

import { Html, Button } from '@react-email/components';
import * as React from 'react';
interface EmailProps {
link: string;
}
export const Email: React.FC = ({
link,
}) => (
<Html lang="en" dir="ltr">
<Button href={link} style={{ color: '#61dafb' }}>
Click me
</Button>
</Html>
);
import { EmailTemplate } from '@/components/email-template';
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST() {
const { data, error } = await resend.emails.send({
from: 'onboarding@resend.dev',
to: 'delivered@resend.dev',
subject: 'Hello world',
react: EmailTemplate({ firstName: 'John' }),
});
if (error) {
return Response.json({ error });
}
return Response.json(data);
}

Integrate with the Next.js App Router

The App Router is a new paradigm for building applications using React Server Components. Resend is compatible with the App Router and the latest versions of Next.js.

Send Form Emails with Server Actions

Integrate Resend with Server Actions by defining an asynchronous function with the "use server" directive at the top of the function body. This will ensure that Resend is only executed on the server.

import { Resend } from 'resend';
export default async function Page() {
async function send() {
'use server';
const resend = new Resend(process.env.RESEND_API_KEY);
const { data } = await resend.emails.send({
from: 'Acme <onboarding@resend.dev>',
to: ['delivered@resend.dev'],
subject: 'Hello World',
html: '<strong>It works!</strong>'
});
console.log(data);
}
return (
<form action={send}>
<button type="submit">Send email</button>
</form>
)
}
import type { NextApiRequest, NextApiResponse } from 'next';
import { EmailTemplate } from '@/components/email-template';
import { Resend } from 'resend';
const resend = new Resend('re_123456789');
export default async (req: NextApiRequest, res: NextApiResponse) => {
const { data, error } = await resend.emails.send({
from: 'onboarding@resend.dev',
to: 'delivered@resend.dev',
subject: 'Hello World',
react: EmailTemplate({ firstName: 'John' }),
});
if (error) {
return res.status(400).json(error);
}
return res.status(200).json(data);
}

Works with the Pages Router

Before Next.js 13, the Pages Router was the main way to create routes. The Pages Router is still supported in newer versions of Next.js and can be used with Resend.

"I've added emails to my site in 30 minutes. Resend is amazing."
Lee Robinson

Lee Robinson

VP of Product at Vercel

All you need to get started

Resources to help you integrate email into your application quickly.

Next.js Quickstart

Follow the step-by-step guide and learn how to send your first email using Next.js.

Next.js Example

Clone the example repository to get started quickly with Resend using Next.js.

API Reference

Understand the REST API endpoints and each of the parameters that can be used.

  • "Our team loves Resend. It makes email sending so easy and reliable. After we switched to Dedicated IPs, our deliverability improved tremendously and we don't hear complaints about emails landing on spam anymore."
    Vlad Matsiiako
    Vlad Matsiiako
    Vlad MatsiiakoCo-founder of Infisical
  • "I've used Mailgun, Sendgrid, and Mandrill and they don't come close to providing the quality of developer experience you get with Resend."
    Brandon Strittmatter
    Brandon Strittmatter
    Brandon StrittmatterCo-founder of Outerbase
  • "Resend is an amazing product. It was so easy to switch over. I feel confident knowing that our important emails are in good hands with Resend. Everyone should be using this."
    Shariar Kabir
    Shariar Kabir
    Shariar KabirFounder at Ruby Card
  • "All of our customers are located in South America, so having a solution that could send emails from the region closest to our users is very important. Resend's multi-region feature is a game-changer for us."
    Giovanni Keppelen
    Giovanni Keppelen
    Giovanni KeppelenCTO & Partner at VOA Hoteis
  • "The speed and ease of integrating with the product was incredible, but what really stood out was their intricate knowledge of email and relentless support day or night. Oh and we also ended up winning Product of the week."
    Sam Ducker
    Sam Ducker
    Sam DuckerCo-founder of Anyone
  • "As a developer I love the approach that the Resend team is taking. Its so refreshing. They are also extremely user-centric and helpful in terms of getting you up and running, sending beautiful emails that deliver."
    Hahnbee Lee
    Hahnbee Lee
    Hahnbee LeeCo-Founder at Mintlify
  • "The Resend team have built a great product in a space that hasn't seen 10x innovation for years. Engineering peers are raving about Resend - it's such a smoother dev experience."
    Roberto Riccio
    Roberto Riccio
    Roberto RiccioHead of Product at Alliance
  • "If you're a developer or working on a startup, you're going to love Resend's approach to emailing."
    Joe DeMaria
    Joe DeMaria
    Joe DeMariaCo-founder & CEO of SpecCheck
  • "We were up and running with Resend in no time. It was seamless to integrate into our existing workflow and gave us a tremendous amount of visibility into our email capabilities. Simple to say, it was a no-brainer."
    Ty Sharp
    Ty Sharp
    Ty SharpCo-founder & CEO of InBuild
  • "Resend not only streamlines our emails to accommodate our expanding customer base, but their team also offered valuable hands-on support during the transition from our old API. Their product is visually stunning and seamlessly integrates with React Email."
    Thiago Costa
    Thiago Costa
    Thiago CostaCo-founder of Fey and Narative
  • "As of our last deployment all of our emails are using Resend. We are loving the development experience of React Email - not having to leave my dev environment to develop new emails is a game-changer."
    Adam Rankin
    Adam Rankin
    Adam RankinFounding Engineer at Warp
  • "Working with Resend has been amazing. By using Webhooks, I'm able to track email opened/clicked events via Segment and log those events in LogSnag for visibility. I highly believe in the people behind Resend."
    Taylor Facen
    Taylor Facen
    Taylor FacenFounder of Finta
  • "Resend is super easy to set up. Loving the modern approach the team is taking with supercharging email. Never been a fan of other clunky tools."
    Brek Goin
    Brek Goin
    Brek GoinFounder of Hammr
  • "Our team loves Resend. It makes email sending so easy and reliable. After we switched to Dedicated IPs, our deliverability improved tremendously and we don't hear complaints about emails landing on spam anymore."
    Vlad Matsiiako
    Vlad Matsiiako
    Vlad MatsiiakoCo-founder of Infisical
  • "I've used Mailgun, Sendgrid, and Mandrill and they don't come close to providing the quality of developer experience you get with Resend."
    Brandon Strittmatter
    Brandon Strittmatter
    Brandon StrittmatterCo-founder of Outerbase
  • "Resend is an amazing product. It was so easy to switch over. I feel confident knowing that our important emails are in good hands with Resend. Everyone should be using this."
    Shariar Kabir
    Shariar Kabir
    Shariar KabirFounder at Ruby Card
  • "All of our customers are located in South America, so having a solution that could send emails from the region closest to our users is very important. Resend's multi-region feature is a game-changer for us."
    Giovanni Keppelen
    Giovanni Keppelen
    Giovanni KeppelenCTO & Partner at VOA Hoteis
  • "The speed and ease of integrating with the product was incredible, but what really stood out was their intricate knowledge of email and relentless support day or night. Oh and we also ended up winning Product of the week."
    Sam Ducker
    Sam Ducker
    Sam DuckerCo-founder of Anyone
  • "As a developer I love the approach that the Resend team is taking. Its so refreshing. They are also extremely user-centric and helpful in terms of getting you up and running, sending beautiful emails that deliver."
    Hahnbee Lee
    Hahnbee Lee
    Hahnbee LeeCo-Founder at Mintlify
  • "The Resend team have built a great product in a space that hasn't seen 10x innovation for years. Engineering peers are raving about Resend - it's such a smoother dev experience."
    Roberto Riccio
    Roberto Riccio
    Roberto RiccioHead of Product at Alliance
  • "If you're a developer or working on a startup, you're going to love Resend's approach to emailing."
    Joe DeMaria
    Joe DeMaria
    Joe DeMariaCo-founder & CEO of SpecCheck
  • "We were up and running with Resend in no time. It was seamless to integrate into our existing workflow and gave us a tremendous amount of visibility into our email capabilities. Simple to say, it was a no-brainer."
    Ty Sharp
    Ty Sharp
    Ty SharpCo-founder & CEO of InBuild
  • "Resend not only streamlines our emails to accommodate our expanding customer base, but their team also offered valuable hands-on support during the transition from our old API. Their product is visually stunning and seamlessly integrates with React Email."
    Thiago Costa
    Thiago Costa
    Thiago CostaCo-founder of Fey and Narative
  • "As of our last deployment all of our emails are using Resend. We are loving the development experience of React Email - not having to leave my dev environment to develop new emails is a game-changer."
    Adam Rankin
    Adam Rankin
    Adam RankinFounding Engineer at Warp
  • "Working with Resend has been amazing. By using Webhooks, I'm able to track email opened/clicked events via Segment and log those events in LogSnag for visibility. I highly believe in the people behind Resend."
    Taylor Facen
    Taylor Facen
    Taylor FacenFounder of Finta
  • "Resend is super easy to set up. Loving the modern approach the team is taking with supercharging email. Never been a fan of other clunky tools."
    Brek Goin
    Brek Goin
    Brek GoinFounder of Hammr

Start sending this afternoon

Resend delivers mission-critical emails for some of the fastest growing teams.

Sign up for free