Render modes
The Node.js SDK exposes two ways to describe what to render: project mode (a stored template at project/template) and inline mode (raw HTML you pass directly).
Project mode is required by all the PDF-producing methods (render.pdf, render.pdfStream, render.document, and the renderToFile helper). Inline mode is supported only by render.preview, which returns HTML rather than PDF bytes — useful for debugging template data without engaging the PDF pipeline.
Project mode
Section titled “Project mode”You reference a template by its project and template slugs, plus a data object that fills the template’s placeholders. Optionally pin a version.
const pdf = await client.render.pdf({ project: 'billing', template: 'invoice', data: { invoiceNumber: 'INV-001', total: 1280 },});Project mode keeps templates centralized — anyone with dashboard access can edit them without touching code.
Inline mode (preview only)
Section titled “Inline mode (preview only)”For one-off layout experiments, pass the HTML directly. The template field accepts a string when there’s no project:
const preview = await client.render.preview({ template: '<h1>Hello {{ name }}</h1>', data: { name: 'World' },});Inline mode only works with render.preview. To turn inline HTML into a PDF, save it as a template in the dashboard first, then use project mode.
Example
Section titled “Example”import { PoliPage } from '@poli-page/sdk';
const client = new PoliPage({ apiKey: process.env.POLI_PAGE_API_KEY! });
// Project mode — PDFconst invoicePdf = await client.render.pdf({ project: 'billing', template: 'invoice', data: { invoiceNumber: 'INV-001', total: 1280 },});
// Inline mode — preview HTML onlyconst greeting = await client.render.preview({ template: '<h1>Hello {{ name }}</h1>', data: { name: 'World' },});