
React Pdf
Turn json-render Spec JSON into invoice, report, or contract PDFs using @json-render/react-pdf and @react-pdf/renderer APIs.
Overview
react-pdf is an agent skill for the Build phase that generates PDF documents from json-render JSON specs using @json-render/react-pdf.
Install
npx skills add https://github.com/vercel-labs/json-render --skill react-pdfWhat is this skill?
- Renders json-render Spec trees to PDF via @react-pdf/renderer
- APIs: renderToBuffer, renderToStream, and renderToFile
- Document, Page, Heading, and Table element types in quick-start spec
- npm install path for @json-render/core and @json-render/react-pdf
- Quick-start spec includes Document, Page, Heading, and Table element types
- Three render APIs: renderToBuffer, renderToStream, renderToFile
Adoption & trust: 1.2k installs on skills.sh; 15k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a JSON spec for document layout but no clear agent-guided path to PDF buffers, streams, or files in Node.
Who is it for?
Builders using the json-render stack who need programmatic invoices, reports, or exports in a TypeScript codebase.
Skip if: Pixel-perfect brand PDFs that require dedicated InDesign workflows or heavy custom font licensing outside the React PDF model.
When should I use this skill?
Use when generating PDF documents from JSON specs, working with @json-render/react-pdf, or rendering specs to PDF buffers, streams, or files.
What do I get? / Deliverables
You implement renderToBuffer, renderToStream, or renderToFile against a typed Spec ready to attach to API routes or jobs.
- PDF buffer or file
- Streamable PDF for HTTP responses
- Typed Spec example for invoices or reports
Recommended Skills
Journey fit
How it compares
Skill package for json-render PDF output—not a separate MCP server or a generic HTML-to-PDF screenshot tool.
Common Questions / FAQ
Who is react-pdf for?
Solo and indie developers on the json-render ecosystem who want agent help wiring React PDF rendering into their app.
When should I use react-pdf?
During build when you are generating PDFs from JSON specs, adding invoice or report endpoints, or piping PDF streams to HTTP responses.
Is react-pdf safe to install?
Review the Security Audits panel on this Prism page and vet npm dependencies (@json-render/react-pdf, @react-pdf/renderer) in your lockfile.
SKILL.md
READMESKILL.md - React Pdf
# @json-render/react-pdf React PDF renderer that generates PDF documents from JSON specs using `@react-pdf/renderer`. ## Installation ```bash npm install @json-render/core @json-render/react-pdf ``` ## Quick Start ```typescript import { renderToBuffer } from "@json-render/react-pdf"; import type { Spec } from "@json-render/core"; const spec: Spec = { root: "doc", elements: { doc: { type: "Document", props: { title: "Invoice" }, children: ["page"] }, page: { type: "Page", props: { size: "A4" }, children: ["heading", "table"], }, heading: { type: "Heading", props: { text: "Invoice #1234", level: "h1" }, children: [], }, table: { type: "Table", props: { columns: [ { header: "Item", width: "60%" }, { header: "Price", width: "40%", align: "right" }, ], rows: [ ["Widget A", "$10.00"], ["Widget B", "$25.00"], ], }, children: [], }, }, }; const buffer = await renderToBuffer(spec); ``` ## Render APIs ```typescript import { renderToBuffer, renderToStream, renderToFile } from "@json-render/react-pdf"; // In-memory buffer const buffer = await renderToBuffer(spec); // Readable stream (pipe to HTTP response) const stream = await renderToStream(spec); stream.pipe(res); // Direct to file await renderToFile(spec, "./output.pdf"); ``` All render functions accept an optional second argument: `{ registry?, state?, handlers? }`. ## Standard Components | Component | Description | |-----------|-------------| | `Document` | Top-level PDF wrapper (must be root) | | `Page` | Page with size (A4, LETTER), orientation, margins | | `View` | Generic container (padding, margin, background, border) | | `Row`, `Column` | Flex layout with gap, align, justify | | `Heading` | h1-h4 heading text | | `Text` | Body text (fontSize, color, weight, alignment) | | `Image` | Image from URL or base64 | | `Link` | Hyperlink with text and href | | `Table` | Data table with typed columns and rows | | `List` | Ordered or unordered list | | `Divider` | Horizontal line separator | | `Spacer` | Empty vertical space | | `PageNumber` | Current page number and total pages | ## Custom Catalog ```typescript import { defineCatalog } from "@json-render/core"; import { schema, defineRegistry, renderToBuffer } from "@json-render/react-pdf"; import { standardComponentDefinitions } from "@json-render/react-pdf/catalog"; import { z } from "zod"; const catalog = defineCatalog(schema, { components: { ...standardComponentDefinitions, Badge: { props: z.object({ label: z.string(), color: z.string().nullable() }), slots: [], description: "A colored badge label", }, }, actions: {}, }); const { registry } = defineRegistry(catalog, { components: { Badge: ({ props }) => ( <View style={{ backgroundColor: props.color ?? "#e5e7eb", padding: 4 }}> <Text>{props.label}</Text> </View> ), }, }); const buffer = await renderToBuffer(spec, { registry }); ``` ## External Store (Controlled Mode) Pass a `StateStore` for full control over state: ```typescript import { createStateStore } from "@json-render/react-pdf"; const store = createStateStore({ invoice: { total: 100 } }); store.set("/invoice/total", 200); ``` ## Server-Safe Import Import schema and catalog without pulling in React: ```typescript import { schema, standardComponentDefinitions } from "@json-render/react-pdf/server"; ```