Skip to content
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RESEND_API_KEY=
28 changes: 11 additions & 17 deletions app/api/send/route.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
const RESEND_API_KEY = 're_123456789';
import { Resend } from "resend";

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

export async function POST() {
const res = await fetch('https://api.resend.com/emails', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${RESEND_API_KEY}`,
},
body: JSON.stringify({
from: 'Acme <onboarding@resend.dev>',
to: ['delivered@resend.dev'],
subject: 'hello world',
html: '<strong>it works!</strong>',
}),
const response = await resend.emails.send({
from: 'Acme <onboarding@resend.dev>',
to: ['delivered@resend.dev'],
subject: 'hello world',
html: '<strong>it works!</strong>',
});

if (res.ok) {
const data = await res.json();
return Response.json(data);
}
return Response.json(response, {
status: response.error ? 500 : 200,
});
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"private": true,
"scripts": {
"dev": "next dev --turbo",
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^14.2.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"resend": "^3.2.0"
"next": "^16.0.1",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"resend": "^6.4.0"
},
"devDependencies": {
"@types/node": "20.19.4",
"@types/react": "18.3.3",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"typescript": "5.8.3"
}
}
Loading