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/hono

v0.7.6

Published

PDF middleware and responses for Hono — works on Workers, Deno, Bun, Node

Downloads

1,131

Readme

@formepdf/hono

PDF generation for Hono. Middleware or standalone helpers. Runs on Cloudflare Workers, Deno, Bun, and Node.

Install

npm install @formepdf/hono @formepdf/react @formepdf/core hono

Quick Start

import { Hono } from 'hono';
import { formePdf } from '@formepdf/hono';

const app = new Hono();
app.use(formePdf());

app.get('/invoice/:id', async (c) => {
  const invoice = await db.invoices.findById(c.req.param('id'));

  return c.pdf('invoice', {
    invoiceNumber: invoice.number,
    date: invoice.date,
    dueDate: invoice.dueDate,
    company: { name: 'Acme Corp', initials: 'AC', address: '123 Main St', cityStateZip: 'San Francisco, CA 94105', email: '[email protected]' },
    billTo: invoice.customer,
    shipTo: invoice.shipping,
    items: invoice.lineItems,
    taxRate: 0.08,
    paymentTerms: 'Net 30',
  });
});

export default app;

Without Middleware

import { pdfResponse } from '@formepdf/hono';

app.get('/invoice/:id', async (c) => {
  const data = await fetchInvoiceData(c.req.param('id'));
  return pdfResponse('invoice', data);
});

Custom Templates

import { MyReport } from './templates/report';

app.get('/report', async (c) => {
  const data = await fetchReportData();

  return c.pdf(() => MyReport(data), {
    filename: 'quarterly-report.pdf',
  });
});

Download vs Preview

// Opens in browser PDF viewer (default)
return c.pdf('invoice', data);

// Forces download dialog
return c.pdf('invoice', data, { download: true });

// Custom filename + download
return c.pdf('invoice', data, { filename: 'invoice-001.pdf', download: true });

Cloudflare Workers

// src/index.ts
import { Hono } from 'hono';
import { formePdf } from '@formepdf/hono';

const app = new Hono();
app.use(formePdf());

app.get('/invoice', async (c) => {
  return c.pdf('invoice', {
    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',
  });
});

export default app;
# wrangler.toml
name = "pdf-api"
compatibility_date = "2024-01-01"
wrangler deploy

PDF API running at the edge. No servers, no Puppeteer, no headless Chrome.

API

formePdf(options?)

Returns Hono middleware that adds c.pdf() to the context.

| Option | Type | Default | Description | |--------|------|---------|-------------| | defaultDownload | boolean | false | Default disposition for all responses |

c.pdf(template, data, options?)

Render a built-in template and return as Response.

c.pdf(renderFn, options?)

Render a custom template and return as Response.

pdfResponse(template, data, options?)

Standalone function. Returns a Response with the PDF. No middleware required.

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | filename | string | {template}.pdf | Filename in Content-Disposition | | download | boolean | false | Force download vs browser preview |

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 |

Why Hono + Forme

Forme's engine is Rust compiled to WASM. It runs anywhere JavaScript runs, including edge runtimes where Puppeteer can't. If you're building an API on Cloudflare Workers and need PDF generation, Forme is one of the only options.

Links