Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add resend example.

thorwebdev0c817dbd2460
diff --git a/examples/edge-functions/supabase/.env.local.example b/examples/edge-functions/supabase/.env.local.example
index 6e5ce0b236a..28cf14f6838 100644
--- a/examples/edge-functions/supabase/.env.local.example
+++ b/examples/edge-functions/supabase/.env.local.example
@@ -21,6 +21,9 @@ https://supabase.com/dashboard/project/_/settings/database
# puppeteer
PUPPETEER_BROWSERLESS_IO_TOKEN=
+# send-email-resend
+RESEND_API_KEY=
+
# send-email-smtp
SMTP_HOSTNAME="your.hostname.com"
SMTP_PORT="2587"
diff --git a/examples/edge-functions/supabase/functions/send-email-resend/README.md b/examples/edge-functions/supabase/functions/send-email-resend/README.md
new file mode 100644
index 00000000000..1dc7d0f8504
--- /dev/null
+++ b/examples/edge-functions/supabase/functions/send-email-resend/README.md
@@ -0,0 +1,38 @@
+# Resend with Supabase Edge Functions
+
+This example shows how to use Resend with [Supabase Edge Functions](https://supabase.com/docs/guides/functions).
+
+## Prerequisites
+
+To get the most out of this example, you’ll need to:
+
+- [Create an API key](https://resend.com/api-keys)
+- [Verify your domain](https://resend.com/domains)
+- Create your `.env` file and set your `RESEND_API_KEY`
+
+```bash
+cp .env.example .env
+```
+
+## Instructions
+
+1. Make sure you have the latest version of the [Supabase CLI](https://supabase.com/docs/guides/cli#installation) installed.
+
+2. Run function locally:
+
+```sh
+supabase start
+supabase functions serve --no-verify-jwt --env-file ./supabase/.env.local
+```
+
+GET http://localhost:54321/functions/v1/send-email-resend
+
+3. Deploy function to Supabase:
+
+```sh
+supabase functions deploy resend --no-verify-jwt
+```
+
+## License
+
+MIT License
diff --git a/examples/edge-functions/supabase/functions/send-email-resend/index.ts b/examples/edge-functions/supabase/functions/send-email-resend/index.ts
new file mode 100644
index 00000000000..05dbb337ecb
--- /dev/null
+++ b/examples/edge-functions/supabase/functions/send-email-resend/index.ts
@@ -0,0 +1,30 @@
+import { serve } from 'https://deno.land/[email protected]/http/server.ts'
+
+const RESEND_API_KEY = Deno.env.get('RESEND_API_KEY')
+
+const handler = async (_request: Request): Promise<Response> => {
+ const res = await fetch('https://api.resend.com/emails', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${RESEND_API_KEY}`,
+ },
+ body: JSON.stringify({
+ subject: 'hello world',
+ html: '<strong>it works!</strong>',
+ }),
+ })
+
+ const data = await res.json()
+
+ return new Response(JSON.stringify(data), {
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+}
+
+serve(handler)