GithubHelp home page GithubHelp logo

resend / resend-nextjs-pages-router-example Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 8.0 36 KB

This example shows how to use Resend with Next.js (Pages Router)

Home Page: https://resend.com/docs/send-with-nextjs

License: MIT License

TypeScript 84.67% JavaScript 15.33%

resend-nextjs-pages-router-example's Introduction

Resend with Next.js (Pages Router)

This example shows how to use Resend with Next.js.

Deploy your own

Deploy the example using Vercel:

Deploy with Vercel

Instructions

  1. Define environment variables in .env file.
cp .env.example .env
  1. Install dependencies:
npm install
# or
yarn
  1. Run Next.js locally:
npm run dev
  1. Open URL in the browser:
http://localhost:3000/api/send

License

MIT License

resend-nextjs-pages-router-example's People

Contributors

zenorocha avatar bukinoshita avatar dependabot[bot] avatar jayanratna avatar renovate[bot] avatar

Stargazers

Akmal avatar Sahil Hussain avatar Ali Tas avatar Josh Cain avatar Ian Young avatar Andrejs Agejevs avatar Luke Doig avatar Dody avatar patcodes avatar Alex Galhardo avatar gursidak_singh avatar Shivam Jha avatar Dimeji Ogunleye avatar hillkim avatar

Watchers

 avatar

resend-nextjs-pages-router-example's Issues

What is the best way to send two different emails to two different users?

I am able to send the email to player1 but not player2. I know I can pass an array of strings to 'to' but then both users can see eachothers email. Any ideas? Sorry if it's a stupid question I am very new to nextjs and node


import type { NextApiRequest, NextApiResponse } from "next";
import { EmailTemplate } from "../../components/emails/EmailTemplate";
import { Resend } from "resend";
import { supabase } from "../../../initSupabase";

const resend = new Resend(process.env.NEXT_PUBLIC_RESEND_KEY);

export default async (req: NextApiRequest, res: NextApiResponse) => {
  try {
    const { player1, player2, player1Email, player2Email } = req.body;

    const player1Data = await resend.emails.send({
      from: "Acme <[email protected]>",
      to: [player1Email],
      subject: "Hello player 1",
      react: EmailTemplate({ firstName: player1, secondName: player1Email }),
    });

    const player2Data = await resend.emails.send({
      from: "Acme <[email protected]>",
      to: [player2Email],
      subject: "Hello player 2",
      react: EmailTemplate({ firstName: player2, secondName: player2Email }),
    });

    res.status(200).json({ player1Data, player2Data });
  } catch (error) {
    res.status(400).json(error);
  }
};

Any ideas how to achieve this?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

npm
package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.