The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add resend exmaple n docs.
thorwebdeva783f466aa3f
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 2b4532a1aae..aa1116135d7 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -758,6 +758,7 @@ export const functions: NavMenuConstant = {{ name: 'Browserless.io', url: '/guides/functions/examples/screenshots' },{ name: 'Hugging Face', url: '/guides/ai/examples/huggingface-image-captioning' },{ name: 'OpenAI API', url: '/guides/ai/examples/openai' },+ { name: 'Sending Emails with Resend', url: '/guides/functions/examples/send-emails' },{ name: 'Upstash Redis', url: '/guides/functions/examples/upstash-redis' },{ name: 'Type-Safe SQL with Kysely', url: '/guides/functions/kysely-postgres' },],diff --git a/apps/docs/pages/guides/functions.mdx b/apps/docs/pages/guides/functions.mdxindex 2ff6be47042..990b4925cc2 100644--- a/apps/docs/pages/guides/functions.mdx+++ b/apps/docs/pages/guides/functions.mdx@@ -130,8 +130,8 @@ export const examples = [},{name: 'Send emails',- description: `Send emails in Edge Functions.`,- href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/send-email-smtp',+ description: `Send emails in Edge Functions with Resend.`,+ href: '/guides/functions/examples/send-emails',},{name: 'Web Stream',diff --git a/apps/docs/pages/guides/functions/examples/send-emails.mdx b/apps/docs/pages/guides/functions/examples/send-emails.mdxnew file mode 100644index 00000000000..6f7b52ab51a--- /dev/null+++ b/apps/docs/pages/guides/functions/examples/send-emails.mdx@@ -0,0 +1,91 @@+import Layout from '~/layouts/DefaultGuideLayout'++export const meta = {+ title: 'Sending Emails',+ description: 'Sending emails from Edge Functions using the Resend API.',+}++Sending emails from Edge Functions using the [Resend API](https://resend.com/).++### 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)++Make sure you have the latest version of the [Supabase CLI](https://supabase.com/docs/guides/cli#installation) installed.++### 1. Create Supabase function++Create a new function locally:++```bash+supabase functions new resend+```++Store the `RESEND_API_KEY` in your `.env` file.++### 2. Edit the handler function++Paste the following code into the `index.ts` file:++```tsx+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({+ from: '[email protected]',+ to: '[email protected]',+ 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)+```++### 3. Deploy and send email++Run function locally:++```bash+supabase start+supabase functions serve --no-verify-jwt --env-file .env+```++Test it: http://localhost:54321/functions/v1/resend++Deploy function to Supabase:++```bash+supabase functions deploy resend --no-verify-jwt+```++Open the endpoint URL to send an email:++### 4. Try it yourself++Find the complete example on [GitHub](https://github.com/resendlabs/resend-supabase-edge-functions-example).++export const Page = ({ children }) => <Layout meta={meta} children={children} />++export default Page