├── .env.example ├── .gitignore ├── renovate.json ├── app └── api │ └── send │ └── route.ts ├── package.json ├── README.md ├── tsconfig.json └── LICENSE /.env.example: -------------------------------------------------------------------------------- 1 | RESEND_API_KEY= 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .next 3 | .vercel 4 | node_modules 5 | next-env.d.ts -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /app/api/send/route.ts: -------------------------------------------------------------------------------- 1 | import { Resend } from "resend"; 2 | 3 | const resend = new Resend(process.env.RESEND_API_KEY); 4 | 5 | export async function POST() { 6 | const response = await resend.emails.send({ 7 | from: 'Acme ', 8 | to: ['delivered@resend.dev'], 9 | subject: 'hello world', 10 | html: 'it works!', 11 | }); 12 | 13 | return Response.json(response, { 14 | status: response.error ? 500 : 200, 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "next dev", 5 | "build": "next build", 6 | "start": "next start" 7 | }, 8 | "dependencies": { 9 | "next": "^16.0.1", 10 | "react": "^19.2.0", 11 | "react-dom": "^19.2.0", 12 | "resend": "^6.4.0" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "24.10.1", 16 | "@types/react": "^19.2.2", 17 | "@types/react-dom": "^19.2.2", 18 | "typescript": "5.8.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Resend with Vercel Functions 2 | 3 | This example shows how to use Resend with [Vercel Functions](https://vercel.com/docs/functions). 4 | 5 | ## Prerequisites 6 | 7 | To get the most out of this guide, you’ll need to: 8 | 9 | - [Create an API key](https://resend.com/api-keys) 10 | - [Verify your domain](https://resend.com/domains) 11 | 12 | ## Instructions 13 | 14 | 1. Install dependencies: 15 | 16 | ```sh 17 | pnpm install 18 | ``` 19 | 20 | 2. Run Next.js locally: 21 | 22 | ```sh 23 | pnpm run dev 24 | ``` 25 | 26 | 3. Open URL in the browser: 27 | 28 | ``` 29 | http://localhost:3000/api/send 30 | ``` 31 | 32 | ## License 33 | 34 | MIT License 35 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "incremental": true, 15 | "esModuleInterop": true, 16 | "module": "esnext", 17 | "resolveJsonModule": true, 18 | "moduleResolution": "node", 19 | "isolatedModules": true, 20 | "jsx": "react-jsx", 21 | "plugins": [ 22 | { 23 | "name": "next" 24 | } 25 | ] 26 | }, 27 | "include": [ 28 | "next-env.d.ts", 29 | "**/*.ts", 30 | "**/*.tsx", 31 | ".next/types/**/*.ts", 32 | ".next/dev/types/**/*.ts" 33 | ], 34 | "exclude": [ 35 | "node_modules" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Plus Five Five, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------