Introduction

React Email is a library for building emails with React. In this guide, we will show you how to use weeSend with React Email.

Install dependencies

npm install weesend @react-email/render

Create an email template

import * as React from "react";
import { Html } from "@react-email/html";
import { Button } from "@react-email/button";

export function Email(props) {
  const { url } = props;

  return (
    <Html lang="en">
      <Button href={url}>Click me</Button>
    </Html>
  );
}

Send an email using weeSend

import { WeeSend } from "weesend";
import { render } from "@react-email/render";
import { Email } from "./email";

const weesend = new WeeSend("us_your_weesend_api_key");

  const html = await render(<Email url="https://weesend.com" />);

const response = await weesend.emails.send({
  to: "hello@weesend.com",
  from: "hello@weesend.com",
  subject: "weeSend email",
  html,
});

Build your project

JavaScript

If you’re using nodejs, importing email.jsx might fail. make sure to add these to your babel config:
{
  "plugins": ["@babel/plugin-proposal-class-properties"]
}
Checkout this example

TypeScript

Just add jsx to your tsconfig.json
{
  "compilerOptions": { "jsx": "react-jsx" }
}
Checkout this example