Socket
Book a DemoInstallSign in
Socket

@weweb/backend-resend

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@weweb/backend-resend

Resend integration for WeWeb backend services

latest
npmnpm
Version
0.2.3
Version published
Maintainers
4
Created
Source

WeWeb Resend Integration

A WeWeb backend integration for Resend's email API, providing robust email sending capabilities within WeWeb backend workflows. This integration uses the official resend package for reliable email delivery with features like HTML templates, attachments, and tracking.

Features

  • Simple integration with Resend's email API
  • Send transactional emails with HTML or plain text content
  • Support for CC, BCC, and reply-to fields
  • File attachments support
  • Email tracking capabilities
  • Domain management functions
  • API key management

Installation

This package is designed to work with the WeWeb Supabase Backend Builder and Deno.

import { serve } from '@weweb/backend-core';
import { createResendIntegration } from '@weweb/backend-resend';

Usage

Basic Setup

import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Resend from '@weweb/backend-resend';

// Define your backend configuration
const config: BackendConfig = {
  workflows: [
    // Your workflows here
  ],
  integrations: [
    // Use the default Resend integration
    Resend,
    // Or add other integrations
  ],
  production: false,
};

// Start the server
const server = serve(config);

Custom Configuration

You can customize the Resend client by using the createResendIntegration function:

import { createResendIntegration } from '@weweb/backend-resend';

// Create a custom Resend integration
const customResend = createResendIntegration({
  apiKey: 're_123456789', // Override environment variable
});

If not specified, the integration will use the following environment variable:

  • RESEND_API_KEY - Your Resend API Key

Available Methods

Send Email

Send transactional emails to one or multiple recipients.

// Example workflow action
const config = {
  type: 'action',
  id: 'send_welcome_email',
  actionId: 'resend.send_email',
  inputMapping: [
    {
      from: 'onboarding@yourdomain.com',
      to: '$body.email',
      subject: 'Welcome to Our Platform',
      html: '<h1>Welcome!</h1><p>Thank you for signing up.</p>',
      text: 'Welcome! Thank you for signing up.'
    }
  ]
};

Get Email

Retrieve details about a sent email.

// Example workflow action
const config = {
  type: 'action',
  id: 'get_email_details',
  actionId: 'resend.get_email',
  inputMapping: [
    {
      id: '$body.emailId'
    }
  ]
};

List Emails

Get a list of all sent emails with pagination support.

// Example workflow action
const config = {
  type: 'action',
  id: 'list_recent_emails',
  actionId: 'resend.list_emails',
  inputMapping: [
    {
      limit: 20
    }
  ]
};

Create Domain

Add a new domain to your Resend account.

// Example workflow action
const config = {
  type: 'action',
  id: 'add_new_domain',
  actionId: 'resend.create_domain',
  inputMapping: [
    {
      name: 'marketing.yourdomain.com',
      region: 'us-east-1'
    }
  ]
};

List Domains

Get a list of all domains in your Resend account.

// Example workflow action
const config = {
  type: 'action',
  id: 'get_all_domains',
  actionId: 'resend.list_domains',
  inputMapping: [{}]
};

Example: Complete Email Service Application

import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Resend from '@weweb/backend-resend';

const config: BackendConfig = {
  workflows: [
    {
      path: '/send-email',
      methods: ['POST'],
      security: {
        accessRule: 'public',
      },
      inputsValidation: {
        body: {
          type: 'object',
          properties: {
            to: { type: 'string' },
            subject: { type: 'string' },
            message: { type: 'string' },
            template: { type: 'string', enum: ['welcome', 'password_reset', 'invoice'] }
          },
          required: ['to', 'subject', 'message', 'template'],
        },
      },
      workflow: [
        {
          type: 'action',
          id: 'send_email',
          actionId: 'resend.send_email',
          inputMapping: [
            {
              from: 'support@yourdomain.com',
              to: '$body.to',
              subject: '$body.subject',
              html: `
                {{#if (eq $body.template 'welcome')}}
                  <h1>Welcome to Our Service</h1>
                {{else if (eq $body.template 'password_reset')}}
                  <h1>Password Reset Request</h1>
                {{else if (eq $body.template 'invoice')}}
                  <h1>Your Invoice</h1>
                {{/if}}
                <div>{{$body.message}}</div>
                <footer>© Your Company 2025</footer>
              `,
              text: '$body.message'
            },
          ],
        },
      ],
    },
  ],
  integrations: [Resend],
  production: false,
};

console.log('Starting email service on http://localhost:8000/send-email');
serve(config);

Authentication

This integration uses the official Resend client and requires a Resend API key to function:

You can get your API key from the Resend Dashboard.

Getting Started with Resend

  • Create a Resend account at resend.com
  • Verify your domain to ensure better deliverability
  • Generate an API key from the dashboard
  • Set the RESEND_API_KEY environment variable or provide it in the configuration

Resend offers features like:

  • Email analytics and tracking
  • Bounce handling
  • Template management
  • Webhook integration for delivery status
  • Domain verification for improved deliverability

For full details, see Resend's documentation.

FAQs

Package last updated on 09 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts