Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.hookpdf.com/llms.txt

Use this file to discover all available pages before exploring further.

Use the official HookPDF Node.js SDK to render PDFs from your templates, poll job status, and handle API errors with typed exceptions.

Install

npm i hookpdf
Requires Node.js 18 or later.

Initialize client

CommonJS

const HookPDF = require('hookpdf');

const client = new HookPDF('hp_live_your_api_key');

ES modules

import HookPDF from 'hookpdf';

const client = new HookPDF('hp_live_your_api_key');

Quick start

const HookPDF = require('hookpdf');

const client = new HookPDF('hp_live_your_api_key');

async function run() {
  const job = await client.render({
    templateId: 'your-template-id',
    payload: {
      customer_name: 'John Doe',
      invoice_no: 'INV-2026-001',
      total: 1250.0
    }
  });

  const report = await client.waitForReport(job.jobId);
  console.log('PDF ready:', report.outputUrl);
}

run().catch(console.error);

Preview render

Use renderPreview() when you want a watermarked PDF for testing without consuming credits.
const preview = await client.renderPreview({
  templateId: 'your-template-id',
  payload: { name: 'Test User' }
});

console.log(preview.jobId);

Next steps