Profile
Back to NewsBack
GitHub Trending 6 min
Reader Mode
emailjs-com/emailjs-sdk: EmailJS helps sending emails using client side technologies only. No server is required.

emailjs-com/emailjs-sdk: EmailJS helps sending emails using client side technologies only. No server is required.

16 hours ago

Official EmailJS SDK for Web Browsers

The official client-side TypeScript and JavaScript SDK for EmailJS.com customers.

Send emails directly from your code in the simplest and most secure way.

codecov</a> npm version</a>

  • 100% Code Coverage: Every single line of code, condition, and error handler in this SDK is
fully covered by automated test suites to ensure absolute production readiness and zero regression issues.
  • Zero External Dependencies: Built with zero overhead to keep your bundle footprint as lightweight as possible.

Target Environment Notice

This package is designed exclusively for web browsers and client-side web environments. If you are building for a different platform, please use the corresponding dedicated SDK:

Why EmailJS?

What is EmailJS?

EmailJS is an Email Orchestration Layer and a Unified API hub. We do not operate our own email delivery servers; instead, we sit on top of your existing infrastructure.

You connect your preferred email services—whether it’s a personal Gmail account, a standard SMTP server, or enterprise transactional providers like SendGrid, Resend, Mailgun, or AWS SES.

Core Architectural Benefits

  • Instant Provider Hot-Swapping: If your primary delivery service suffers an outage or an unexpected account block, your application remains online. With EmailJS, you can instantly route your production traffic to a fallback provider (e.g., from SendGrid to AWS SES) with a single click in your dashboard—requiring zero code adjustments and zero re-deployments. You can also route dynamically on the fly by passing a different serviceID directly in your API request.
  • Bypass the "Migration Tax": If you ever need to change your email provider, you don't have to rewrite your integration logic, recreate HTML templates, or re-map variables. Integrate EmailJS once, and change underlying providers seamlessly.
  • Zero Backend Overhead: Eliminate the need to build, maintain, and secure a custom backend service or proxy just to safely route outgoing emails.
  • Universal Ecosystem Support: Works seamlessly across any stack. Use our official client/server SDKs—or connect any application on any platform using our universal REST API with Rust, Python, PHP, C#, Go, or any other language.

Installation and Setup

Modern Bundlers (Vite, Next.js, Webpack, Rollup)

Install the SDK using your preferred package manager:

npm install @emailjs/browser

yarn add @emailjs/browser

pnpm add @emailjs/browser

bun add @emailjs/browser

Browser Direct Script Integration (CDN)

For applications without a build step, websites running on CMS platforms (like WordPress, Webflow, Shopify), or vanilla JavaScript environments, add the SDK directly via CDN:

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/@emailjs/browser@5/dist/email.min.js"
></script>

Code Examples

1. Modern Async/Await Workflow

Designed for components in React, Vue, Angular, Svelte, Next.js, Nuxt, etc.

import emailjs, { EmailJSResponseStatus } from '@emailjs/browser';

const templateParams = { name: 'James', notes: 'Check this out!', };

try { const response = await emailjs.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams, { publicKey: 'YOUR_PUBLIC_KEY', }); console.log('SUCCESS!', response.status, response.text); } catch (error) { if (error instanceof EmailJSResponseStatus) { console.error('EmailJS Error:', error.status, error.text); return; } console.error('Unexpected Error:', error); }

2. Form Submission (sendForm)

Automatically captures input fields from an HTML form element and delivers the payload securely.

import emailjs from '@emailjs/browser';

emailjs .sendForm( 'YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', document.querySelector('#myForm'), // Can be a direct form reference (preferred), or a string selector { publicKey: 'YOUR_PUBLIC_KEY', }, ) .then((response) => { console.log('SUCCESS!', response.status, response.text); }) .catch((error) => { console.error('FAILED...', error); });

3. Vanilla JavaScript Website Integration Example

If you are loading the SDK via a Chat with me