Skip to content

Commit

Permalink
feat: Treat error and formatting
Browse files Browse the repository at this point in the history
zenorocha committed Oct 1, 2024
1 parent 563f8fa commit 09bf237
Showing 4 changed files with 898 additions and 744 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Resend with Example
# Resend with Hono

This example shows how to use Resend with [Hono](https://hono.dev/).

1,613 changes: 883 additions & 730 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/emails/email-template.tsx
Original file line number Diff line number Diff line change
@@ -10,6 +10,4 @@ export const EmailTemplate: React.FC<Readonly<EmailTemplateProps>> = ({
<div>
<h1>Welcome, {firstName}!</h1>
</div>
);

export default EmailTemplate;
);
23 changes: 13 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Hono } from "hono";
import { Resend } from "resend";
import { EmailTemplate } from "./emails/email-template";
import { Hono } from 'hono';
import { Resend } from 'resend';
import { EmailTemplate } from './emails/email-template';

const app = new Hono();
const resend = new Resend('re_123456789');

app.get("/", async (c) => {
const resend = new Resend("re_123456789" /* c.env.RESEND_API_KEY */);

const data = await resend.emails.send({
from: "Acme <onboarding@resend.dev>",
to: ["delivered@resend.dev"],
subject: "hello world",
app.get('/', async (c) => {
const { data, error } = await resend.emails.send({
from: 'Acme <onboarding@resend.dev>',
to: ['delivered@resend.dev'],
subject: 'hello world',
react: <EmailTemplate firstName="John" />,
});

if (error) {
return c.json(error);
}

return c.json(data);
});

0 comments on commit 09bf237

Please sign in to comment.