Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example to latest deps. #30

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
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
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Plus Five Five, Inc.
Copyright (c) 2024 Plus Five Five, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
28 changes: 13 additions & 15 deletions README.md
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
23 changes: 9 additions & 14 deletions app/api/send/route.ts
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);
}
}
5 changes: 0 additions & 5 deletions next-env.d.ts

This file was deleted.

19 changes: 10 additions & 9 deletions package.json
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"
}
}
Loading