{"id":20458720,"url":"https://github.com/resend/resend-cloudflare-workers-example","last_synced_at":"2025-04-13T05:45:57.559Z","repository":{"id":172038182,"uuid":"648752705","full_name":"resend/resend-cloudflare-workers-example","owner":"resend","description":"This example shows how to use Resend with Cloudflare Workers","archived":false,"fork":false,"pushed_at":"2025-04-12T23:45:16.000Z","size":70,"stargazers_count":14,"open_issues_count":14,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T05:45:52.730Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://resend.com/docs/send-with-cloudflare-workers","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/resend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-06-02T18:11:51.000Z","updated_at":"2025-04-04T04:37:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe9e5549-c205-4fb0-85c4-d9ed04f1cf6b","html_url":"https://github.com/resend/resend-cloudflare-workers-example","commit_stats":null,"previous_names":["resendlabs/resend-cloudflare-workers-example","resend/resend-cloudflare-workers-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-cloudflare-workers-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-cloudflare-workers-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-cloudflare-workers-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-cloudflare-workers-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/resend","download_url":"https://codeload.github.com/resend/resend-cloudflare-workers-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670516,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T12:13:37.100Z","updated_at":"2025-04-13T05:45:57.538Z","avatar_url":"https://github.com/resend.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resend with Cloudflare Workers\n\nThis example shows how to use Resend with [Cloudflare Workers](https://workers.cloudflare.com).\n\n## Prerequisites\n\nTo get the most out of this guide, you’ll need to:\n\n* [Create an API key](https://resend.com/api-keys)\n* [Verify your domain](https://resend.com/domains)\n\n## Instructions\n\n### 1. Install\n\nGet the Resend Node.js SDK.\n\n```bash\nnpm install resend\n```\n\n\u003c/CodeGroup\u003e\n\n### 2. Create an email template\n\nStart by creating your email template on `src/emails/email-template.tsx`:\n\n```tsx\nimport * as React from 'react';\n\ninterface EmailTemplateProps {\n  firstName: string;\n}\n\nexport const EmailTemplate: React.FC\u003cReadonly\u003cEmailTemplateProps\u003e\u003e = ({\n  firstName,\n}) =\u003e (\n  \u003cdiv\u003e\n    \u003ch1\u003eWelcome, {firstName}!\u003c/h1\u003e\n  \u003c/div\u003e\n);\n\nexport default EmailTemplate;\n```\n\n### 3. Send the email using React and the SDK\n\nChange the file extension of the worker's main file to `tsx` and modify your configurations.\n\nAfter that, you can send your email using the `react` parameter:\n\n```tsx\nimport { Resend } from 'resend';\nimport { EmailTemplate } from './emails/email-template';\n\nexport default {\n  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise\u003cResponse\u003e {\n    const resend = new Resend('re_123456789');\n\n    const data = await resend.emails.send({\n      from: 'Acme \u003conboarding@resend.dev\u003e',\n      to: ['delivered@resend.dev'],\n      subject: 'hello world',\n      react: \u003cEmailTemplate firstName=\"John\" /\u003e,\n    }):\n\n    return new Response(JSON.stringify(data), {\n      headers: {\n        'Content-Type': 'application/json',\n      },\n    });\n  },\n};\n```\n\n### 4. Deploy and send email\n\nRun `wrangler deploy` and wait for it to finish. Once it's done, it will\ngive you a URL to try out, like `https://my-worker.your_name.workers.dev`,\nthat you can open and verify that your email has been sent.\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresend%2Fresend-cloudflare-workers-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresend%2Fresend-cloudflare-workers-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresend%2Fresend-cloudflare-workers-example/lists"}