> ## 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.

# Node.js SDK

> Install and use the HookPDF Node.js SDK to render PDFs and track jobs.

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

## Install

```bash theme={null}
npm i hookpdf
```

Requires Node.js 18 or later.

## Initialize client

### CommonJS

```javascript theme={null}
const HookPDF = require('hookpdf');

const client = new HookPDF('hp_live_your_api_key');
```

### ES modules

```javascript theme={null}
import HookPDF from 'hookpdf';

const client = new HookPDF('hp_live_your_api_key');
```

## Quick start

```javascript theme={null}
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.

```javascript theme={null}
const preview = await client.renderPreview({
  templateId: 'your-template-id',
  payload: { name: 'Test User' }
});

console.log(preview.jobId);
```

## Next steps

* Read the full [SDK reference](/sdk/reference)
* Learn request and response details in the [REST API reference](/api-reference/introduction)
* Start with a production render endpoint: [POST /render](/api-reference/render/post)
