npm.io
2.22.7 • Published 4d ago

@medusajs/notification-sendgrid

Licence
MIT
Version
2.22.7
Deps
1
Size
15 kB
Vulns
0
Weekly
0
Stars
36.5K

Medusa logo

@medusajs/notification-sendgrid

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

SendGrid Notification Module Provider for Medusa: sends email notifications through SendGrid, using SendGrid dynamic templates or raw HTML content. Use it to send transactional emails, such as order confirmations or password resets. It ships with @medusajs/medusa and is registered through the @medusajs/medusa/notification-sendgrid path.

At a glance

Package @medusajs/notification-sendgrid
Type Module Provider (Notification Module)
Provider ID notification-sendgrid
Registered by default No
Import from @medusajs/medusa/notification-sendgrid

Features

  • Sends a notification's template as a SendGrid dynamic template ID, with the notification's data as the template data.
  • Sends a notification's content (subject and html) instead of a template when it's set.
  • Supports attachments, a per-notification from address, and SendGrid personalizations through provider_data.

Installation

No installation needed. The provider is a dependency of @medusajs/medusa.

Usage

Register the provider in the Notification Module's providers array in medusa-config.ts for the email channel. Each channel can be handled by only one provider.

import { defineConfig } from "@medusajs/framework/utils"

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "@medusajs/medusa/notification",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/notification-sendgrid",
            id: "sendgrid",
            options: {
              channels: ["email"],
              api_key: process.env.SENDGRID_API_KEY,
              from: process.env.SENDGRID_FROM,
            },
          },
        ],
      },
    },
  ],
})

Configuration

Option Type Description Default
channels string[] Read by the Notification Module. The channels this provider handles; use ["email"]. []
api_key string Required. Your SendGrid API key. -
from string Required. The default sender email address. -
Environment variable Description
SENDGRID_API_KEY Value for api_key, as used in the example above.
SENDGRID_FROM Value for from, as used in the example above.

Resources

Keywords