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

@formepdf/resend

v0.7.10

Published

Render a PDF and email it in one call — Forme + Resend

Readme

@formepdf/resend

Render a PDF and email it in one call. Uses Forme for PDF generation and Resend for delivery.

Install

npm install @formepdf/resend resend @formepdf/react @formepdf/core

Quick Start

import { renderDocument } from '@formepdf/core';
import { sendPdf } from '@formepdf/resend';
import { MyInvoice } from './templates/invoice';

// Render the PDF first — works in plain .ts files
const pdfBytes = await renderDocument(MyInvoice({ customer, items }));

// Then email it
const { data, error } = await sendPdf({
  resendApiKey: process.env.RESEND_API_KEY,
  from: 'Acme Corp <[email protected]>',
  to: customer.email,
  subject: 'Invoice #001',
  pdf: pdfBytes,
  filename: 'invoice-001.pdf',
});

Generate the PDF separately, email it with sendPdf. You control the rendering, and the same bytes can go to email + storage + whatever else. Returns Resend's { data, error } directly.

Render Callback

For one-liners in .tsx files:

import { sendPdf } from '@formepdf/resend';
import { MyTemplate } from './my-template';

const { data, error } = await sendPdf({
  resendApiKey: process.env.RESEND_API_KEY,
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Your document',
  render: () => MyTemplate({ name: 'Jane' }),
});

Built-in Templates

Skip the render step and use a built-in template:

import { sendPdf } from '@formepdf/resend';

const { data, error } = await sendPdf({
  resendApiKey: process.env.RESEND_API_KEY,
  from: 'Acme Corp <[email protected]>',
  to: '[email protected]',
  subject: 'Invoice #001',
  template: 'invoice',
  data: {
    invoiceNumber: 'INV-001',
    date: 'February 25, 2026',
    dueDate: 'March 27, 2026',
    company: { name: 'Acme Corp', initials: 'AC', address: '123 Main St', cityStateZip: 'San Francisco, CA 94105', email: '[email protected]' },
    billTo: { name: 'Jane Smith', company: 'Smith Co', address: '456 Oak Ave', cityStateZip: 'Portland, OR 97201', email: '[email protected]' },
    shipTo: { name: 'Jane Smith', address: '456 Oak Ave', cityStateZip: 'Portland, OR 97201' },
    items: [
      { description: 'Consulting', quantity: 10, unitPrice: 150 },
    ],
    taxRate: 0.08,
    paymentTerms: 'Net 30',
  },
});

Add PDF to an Existing Resend Call

import { renderAndAttach } from '@formepdf/resend';
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);
const pdf = await renderAndAttach({ template: 'invoice', data: invoiceData });

await resend.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Your invoice',
  html: '<p>See attached.</p>',
  attachments: [pdf],
});

renderAndAttach returns { filename, content } which is exactly what Resend's attachment API expects.

API

sendPdf(options)

Render a PDF and email it. Returns Resend's { data, error } shape directly.

| Option | Type | Required | Description | |--------|------|----------|-------------| | resendApiKey | string | Yes | Resend API key | | from | string | Yes | Sender address | | to | string \| string[] | Yes | Recipient(s) | | subject | string | Yes | Email subject | | pdf | Uint8Array | One of pdf/render/template | Pre-rendered PDF bytes | | render | () => ReactElement | One of pdf/render/template | Render callback | | template | string | One of pdf/render/template | Built-in template name | | data | object | With template | Data for the template | | filename | string | No | PDF filename (default: {template}.pdf) | | html | string | No | Email body HTML | | text | string | No | Email body plain text | | react | ReactElement | No | React Email component for email body | | cc | string \| string[] | No | CC recipients | | bcc | string \| string[] | No | BCC recipients | | replyTo | string | No | Reply-to address |

When html, text, and react are all omitted, a default email body is generated based on the template type.

renderAndAttach(options)

Render a PDF and return a Resend-compatible attachment object. Does not send.

listTemplates()

Returns available built-in templates with descriptions.

Built-in Templates

| Template | Description | |----------|-------------| | invoice | Line items, tax, totals, company/customer info | | receipt | Payment confirmation, items, total, payment method | | report | Multi-section document with title, headings, body text | | letter | Business letter with letterhead, date, recipient, body | | shipping-label | From/to addresses, 4x6 label format |

Links