Replies: 2 comments 7 replies
-
Hi @Puton1221, Try this code instead import { Hono } from "hono";
import { env } from "hono/adapter";
import { Resend } from "resend";
const app = new Hono<{ Variables: Resend }>(); // I'm not sure of the type, update accordingly
app.use((c) => {
const { mailAPI } = env(c);
const resend = new Resend(mailAPI);
c.set('resend', resend);
});
app.get("/", (c) => {
const resend = c.get('resend');
const { data, error } = await resend.emails.send({
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'Hello World',
html: '<strong>It works!</strong>',
});
return c.text("Successfully sent!");
});
export default app Check this for more info with cf workers and how to use JSX to style the email |
Beta Was this translation helpful? Give feedback.
6 replies
-
Hi @Puton1221. Please try my solution. Install
Use the plugin in your Vite config import { esbuildCommonjs } from '@originjs/vite-plugin-commonjs'
export default {
plugins: [
optimizeDeps: {
esbuildOptions: {
plugins:[
esbuildCommonjs(['resend'])
]
}
}
]
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Resend to create a web page that will send an email when accessing Hono.
I created it with
bun create hono@latest mail-test
and used the cloudflare pages template.And I wrote the following code.
I've been getting errors for a while now, so I made it so that ``new Resend(
${mailAPI}
}` can display "Successfully loaded!" if it succeeds.I have tested it using
vite
.Then I got the following error.
I am having trouble finding much information on the error in detail.
Is there any solution?
Beta Was this translation helpful? Give feedback.
All reactions