Skip to main content

Node.js SDK

The official Node.js SDK for the PDFDyno API makes it simple to generate PDFs from your Node.js or TypeScript backend.

Installation

You can install the SDK directly via npm (or yarn/pnpm):

Usage Example

Initialize the client with your API key and call generatePdf with your template and data.
(Note: The data variable is auto-injected by the backend, so you can access it directly in your template as #data.fieldname)

Next.js (App Router) Example

You can easily use the SDK inside Next.js Server Actions or Route Handlers (app/api/pdf/route.ts).

Error Handling

Handle API errors such as rate limiting gracefully using specific error classes.

TypeScript Support

The @pdfdyno/node SDK is built with TypeScript and includes complete type definitions out of the box, providing auto-completion and compile-time validation for all options.