New to Claude Skills? Learn how to install them →

vercel-labs on GitHub

React PDF Renderer

OfficialFree

Generate PDF documents from JSON specifications effortlessly.

Get this skill

Free · Opens the source repo

What React PDF Renderer does

The React PDF Renderer is a powerful tool designed for developers who need to create PDF documents directly from JSON specifications. Utilizing the @json-render/react-pdf library, it allows for the seamless transformation of structured data into well-formatted PDF files. This skill is particularly useful for applications that require dynamic document generation, such as invoices, reports, or any other structured documents that can be defined in JSON format.

With the React PDF Renderer, you can easily define the layout and content of your PDF using a simple JSON structure. The library supports various components like Document, Page, Heading, Table, and more, enabling you to create complex documents with minimal effort. The rendering process can be done in-memory, streamed, or saved directly to a file, providing flexibility based on your application's needs.

This skill is ideal for developers working in environments where PDF generation is required, such as web applications, server-side rendering, or any project that involves document automation. It simplifies the process of creating PDFs by allowing you to focus on defining your document's content and structure in JSON, while the library handles the rendering details.

Whether you are building an invoicing system, generating reports, or creating any other type of document, the React PDF Renderer provides a straightforward and efficient way to produce high-quality PDF outputs from your JSON data.

When to use it

Use this skill when you need to generate PDF documents dynamically from structured JSON data, especially in web applications or server-side environments.

When not to use it

This skill may not be suitable for projects that require extensive customization of PDF layouts beyond the capabilities of the provided components or for applications that do not utilize JSON for document specifications.

What you can build with it

Generating Invoices

Use the React PDF Renderer to create dynamic invoices from JSON data, allowing for easy customization and updates.

Creating Reports

Generate structured reports by defining the layout and content in JSON, simplifying the reporting process.

Document Automation

Automate the generation of any type of document by leveraging JSON specifications, streamlining workflows.

How to install React PDF Renderer

View source

1. Install with the skills CLI

npx skills add vercel-labs/json-render/react-pdf --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by vercel-labs

@json-render/react-pdf

React PDF renderer that generates PDF documents from JSON specs using @react-pdf/renderer.

Installation

npm install @json-render/core @json-render/react-pdf

Quick Start

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

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

ComponentDescription
DocumentTop-level PDF wrapper (must be root)
PagePage with size (A4, LETTER), orientation, margins
ViewGeneric container (padding, margin, background, border)
Row, ColumnFlex layout with gap, align, justify
Headingh1-h4 heading text
TextBody text (fontSize, color, weight, alignment)
ImageImage from URL or base64
LinkHyperlink with text and href
TableData table with typed columns and rows
ListOrdered or unordered list
DividerHorizontal line separator
SpacerEmpty vertical space
PageNumberCurrent page number and total pages

Custom Catalog

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:

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:

import { schema, standardComponentDefinitions } from "@json-render/react-pdf/server";

Frequently asked questions about React PDF Renderer

Similar skills