Skip to content

Latest commit

 

History

History
107 lines (78 loc) · 2.5 KB

README.md

File metadata and controls

107 lines (78 loc) · 2.5 KB

Medusa v2 Example: Resend Integration

This directory holds the code for the Resend Integration Guide.

You can either:

Prerequisites

Installation

  1. Clone the repository and change to the resend-integration directory:
git clone https://github.com/medusajs/examples.git
cd examples/resend-integration

2. Rename the .env.template file to .env.

3. Set the following environment variables:

RESEND_API_KEY= # Resend API key
RESEND_FROM_EMAIL= # Resend from email. Use onboarding@resend.dev if you don't have a verified domain.

4. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.

5. Install dependencies:

yarn # or npm install

6. Setup and seed the database:

npx medusa db:setup
yarn seed # or npm run seed

7. Start the Medusa application:

yarn dev # or npm run dev

Copy into Existing Medusa Application

If you have an existing Medusa application, copy the content of the following directories:

  1. src/modules/resend
  2. src/workflows
  3. src/subscribers

Then, add the Resend Module to medusa-config.js:

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "@medusajs/medusa/notification",
      options: {
        providers: [
          {
            resolve: "./src/modules/resend",
            id: "resend",
            options: {
              channels: ["email"],
              api_key: process.env.RESEND_API_KEY,
              from: process.env.RESEND_FROM_EMAIL,
            },
          },
        ],
      },
    },
  ]
})

Set the following environment variables:

RESEND_API_KEY= # Resend API key
RESEND_FROM_EMAIL= # Resend from email. Use onboarding@resend.dev if you don't have a verified domain.

And install the following dependencies:

yarn add resend # or npm install resend
yarn add @react-email/components -E # or npm install @react-email/components -E

More Resources