npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

universal-email

v0.0.4

Published

A universal email library supporting multiple providers (SendGrid, Mailgun, UseSend) with TypeScript support

Readme

📧 Universal Email

npm version License: MIT TypeScript

A universal email library that supports multiple providers with a unified API. Send emails seamlessly across different services without changing your code.

✨ Features

  • 🚀 Multiple Providers: Support for SendGrid, Mailgun, and UseSend
  • 🔧 TypeScript First: Full TypeScript support with comprehensive type definitions
  • 🎯 Unified API: Same interface across all providers
  • Zero Dependencies: Lightweight with minimal external dependencies
  • 🔒 Environment Based: Easy configuration through environment variables
  • 📦 Universal: Works in Node.js, Deno, and modern browsers

🚀 Quick Start

Installation

npm install universal-email
# or
pnpm add universal-email
# or
yarn add universal-email

Basic Usage

import { email } from 'universal-email';

// Send an email using the default provider
await email.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello World',
  text: 'Plain text content',
  html: '<h1>Hello World</h1>',
});

🔧 Configuration

Environment Variables

Create a .env file in your project root:

EMAIL_PROVIDER=sendgrid
SENDGRID_API_KEY=your_sendgrid_api_key
MAILGUN_API_KEY=your_mailgun_api_key
MAILGUN_DOMAIN=your_mailgun_domain
USESEND_API_KEY=your_usesend_api_key
USESEND_API_URL=https://app.usesend.com/api/v1

Provider-Specific Configuration

import { useEmail } from 'universal-email';

// Use a specific provider
const sendGrid = useEmail({ provider: 'sendgrid' });
const mailgun = useEmail({ provider: 'mailgun' });
const useSend = useEmail({ provider: 'usesend' });

// Send with specific provider
await sendGrid.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Sent via SendGrid',
  text: 'This email was sent using SendGrid!',
});

📚 Supported Providers

SendGrid

const sendGrid = useEmail({
  provider: 'sendgrid',
  apiKey: 'your_sendgrid_api_key',
});

Mailgun

const mailgun = useEmail({
  provider: 'mailgun',
  apiKey: 'your_mailgun_api_key',
  domain: 'your_mailgun_domain',
});

UseSend

const useSend = useEmail({
  provider: 'usesend',
  apiKey: 'your_usesend_api_key',
  baseUrl: 'your_usesend_api_url',
});

🎯 API Reference

useEmail(config?)it e packa

Creates an email provider instance.

Parameters:

  • config.provider - Provider name ('sendgrid', 'mailgun', 'usesend')
  • config.apiKey - API key for the provider
  • config.domain - Domain (required for Mailgun)

Returns: EmailProvider instance

email.send(options)

Sends an email.

Parameters:

  • options.from - Sender email address
  • options.to - Recipient email address
  • options.subject - Email subject
  • options.text - Plain text content
  • options.html - HTML content

Returns: Promise<void>

🛠️ Development

Prerequisites

  • Node.js 18+
  • pnpm (recommended)

Setup

# Clone the repository
git clone https://github.com/loickal/universal-email.git
cd universal-email

# Install dependencies
pnpm install

# Set up environment variables
cp .env.example .env
# Edit .env with your API keys

Scripts

# Development
pnpm dev          # Start development server
pnpm play         # Run playground

# Building
pnpm build        # Build the library
pnpm clean        # Clean build artifacts

# Testing
pnpm test         # Run tests
pnpm test:watch   # Run tests in watch mode
pnpm test:coverage # Generate coverage report

# Code Quality
pnpm lint         # Run linter
pnpm lint:fix     # Fix linting issues
pnpm format       # Format code
pnpm typecheck    # Type check

# Release
pnpm release      # Build, test, and publish

📝 Examples

Basic Email

import { email } from 'universal-email';

await email.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Welcome to MyApp!',
  text: "Welcome to MyApp! We're excited to have you.",
  html: "<h1>Welcome to MyApp!</h1><p>We're excited to have you.</p>",
});

Multiple Recipients

await email.send({
  from: '[email protected]',
  to: ['[email protected]', '[email protected]'],
  subject: 'Newsletter',
  text: 'Check out our latest newsletter!',
  html: '<h1>Newsletter</h1><p>Check out our latest newsletter!</p>',
});

Error Handling

import { email } from 'universal-email';

try {
  await email.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Test Email',
    text: 'This is a test email',
  });
  console.log('Email sent successfully!');
} catch (error) {
  console.error('Failed to send email:', error);
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments