-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update example to latest deps. (#30)
- Loading branch information
Showing
8 changed files
with
763 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.env | ||
.next | ||
.vercel | ||
node_modules | ||
node_modules | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
# Resend with Vercel Edge Functions | ||
# Resend with Vercel Functions | ||
|
||
This example shows how to use Resend with [Vercel Edge Functions](https://vercel.com). | ||
This example shows how to use Resend with [Vercel Functions](https://vercel.com/docs/functions). | ||
|
||
## Prerequisites | ||
|
||
To get the most out of this guide, you’ll need to: | ||
|
||
* [Create an API key](https://resend.com/api-keys) | ||
* [Verify your domain](https://resend.com/domains) | ||
- [Create an API key](https://resend.com/api-keys) | ||
- [Verify your domain](https://resend.com/domains) | ||
|
||
## Instructions | ||
|
||
1. Install dependencies: | ||
|
||
```sh | ||
npm install | ||
# or | ||
yarn | ||
``` | ||
```sh | ||
pnpm install | ||
``` | ||
|
||
2. Run Next.js locally: | ||
|
||
```sh | ||
npm run dev | ||
``` | ||
```sh | ||
pnpm run dev | ||
``` | ||
|
||
3. Open URL in the browser: | ||
|
||
``` | ||
``` | ||
http://localhost:3000/api/send | ||
``` | ||
``` | ||
|
||
## License | ||
|
||
MIT License | ||
MIT License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import { NextResponse } from "next/server"; | ||
|
||
export const runtime = "edge"; | ||
export const dynamic = "force-dynamic"; | ||
|
||
const RESEND_API_KEY = "re_123456789"; | ||
const RESEND_API_KEY = 're_123456789'; | ||
|
||
export async function POST() { | ||
const res = await fetch("https://api.resend.com/emails", { | ||
method: "POST", | ||
const res = await fetch('https://api.resend.com/emails', { | ||
method: 'POST', | ||
headers: { | ||
"Content-Type": "application/json", | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${RESEND_API_KEY}`, | ||
}, | ||
body: JSON.stringify({ | ||
from: "Acme <[email protected]>", | ||
to: ["[email protected]"], | ||
subject: "hello world", | ||
html: "<strong>it works!</strong>", | ||
from: 'Acme <[email protected]>', | ||
to: ['[email protected]'], | ||
subject: 'hello world', | ||
html: '<strong>it works!</strong>', | ||
}), | ||
}); | ||
|
||
if (res.ok) { | ||
const data = await res.json(); | ||
return NextResponse.json(data); | ||
return Response.json(data); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
{ | ||
"name": "with-vercel-edge-functions", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev" | ||
"dev": "next dev --turbo", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"next": "^14.0.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"resend": "^3.0.0" | ||
"next": "^14.2.3", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"resend": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.5.0", | ||
"@types/react": "18.2.20", | ||
"typescript": "5.3.3" | ||
"@types/node": "20.14.2", | ||
"@types/react": "18.3.3", | ||
"typescript": "5.4.5" | ||
} | ||
} |
Oops, something went wrong.