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

hookpdf

v1.1.0

Published

Official Node.js SDK for the HookPDF API — generate PDFs from HTML templates

Readme

hookpdf

Official Node.js SDK for the HookPDF API — generate professional PDFs from HTML/CSS templates.

npm version Node.js

Install

npm i hookpdf

Requires Node.js 18+. Zero external dependencies.

Quick Start

const HookPDF = require('hookpdf');

const client = new HookPDF('hp_live_your_api_key');

// 1. Start a render job
const job = await client.render({
  templateId: 'your-template-id',
  payload: {
    customer_name: 'John Doe',
    invoice_no: 'INV-2026-001',
    total: 1250.00
  }
});

console.log(`Job queued: ${job.jobId}`);

// 2. Wait for completion and get the PDF URL
const report = await client.waitForReport(job.jobId);
console.log(`PDF ready: ${report.outputUrl}`);

ES Modules

import HookPDF from 'hookpdf';

const client = new HookPDF('hp_live_your_api_key');

API Reference

new HookPDF(apiKey, options?)

Create a new client instance.

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | apiKey | string | — | Your HookPDF API key | | options.baseUrl | string | https://api.hookpdf.com | API base URL | | options.timeout | number | 30000 | Request timeout (ms) |


client.render(params)

Enqueue a PDF render job.

const job = await client.render({
  templateId: 'uuid-here',
  payload: { name: 'John', date: '2026-03-05' },
  options: {
    pageSize: 'A4',           // default: 'A4'
    orientation: 'portrait',   // 'portrait' | 'landscape'
    locale: 'en-US'           // default: 'en-US'
  }
});
// → { jobId, status, isPreview }

client.renderPreview(params)

Same as render() but generates a watermarked, short-lived preview PDF. Does not count toward your credit quota.

const preview = await client.renderPreview({
  templateId: 'uuid-here',
  payload: { name: 'Test' }
});

client.getReport(jobId)

Get the current status of a render job.

const report = await client.getReport('job-uuid');
// → { id, templateId, status, outputUrl, errorCode, errorMessage, isPreview, createdAt, completedAt }

client.waitForReport(jobId, options?)

Poll until the job completes or fails.

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | options.interval | number | 2000 | Polling interval (ms) | | options.timeout | number | 120000 | Max wait time (ms) |

const report = await client.waitForReport(job.jobId, {
  interval: 3000,
  timeout: 60000
});

if (report.outputUrl) {
  console.log('Download:', report.outputUrl);
}

Error Handling

All API errors throw HookPDFError with structured details:

const { HookPDFError } = require('hookpdf');

try {
  await client.render({ templateId: 'bad-id', payload: {} });
} catch (err) {
  if (err instanceof HookPDFError) {
    console.error(err.message);     // Human-readable message
    console.error(err.status);      // HTTP status code (e.g. 401, 429)
    console.error(err.errorCode);   // API error code (e.g. 'INVALID_TEMPLATE')
    console.error(err.requestId);   // Request ID for support
  }
}

TypeScript

Full TypeScript definitions are included out of the box — no @types package needed.

import HookPDF, { Report, HookPDFError } from 'hookpdf';

const client = new HookPDF('hp_live_xxx');
const report: Report = await client.waitForReport('job-id');

Links

License

MIT