Website profiles · Technology insights · Alternatives

react-pdf.org

React renderer for creating PDF files on the browser and server.

No paid content found
Visit website
Profile views 13 Outbound visits 16 Normal
react-pdf Full homepage screenshot

At a glance

Category
Development
Language
English
Paid-content signal
No paid content foundObserved
Registered
2018
Hosting
VercelInferred
HTTPS certificate trusted
PassedObserved
Last updated

Website review

This review may include AI-generated content and is not individually verified. Domain, certificate and other facts come from the observed data on this page.

What is react-pdf?

react-pdf is a React renderer for creating PDF files. Instead of drawing PDFs with a low-level library, you describe the document as React components (think <Document>, <Page>, <View>, <Text>) and react-pdf turns that tree into an actual PDF file. It runs both in the browser and on the server, so the same document code can produce a downloadable file in a web app or a generated file in a Node backend.

What you get

  • React-style composition. You build documents the way you build UI, reusing components and passing props, rather than issuing imperative drawing commands.
  • Flexbox layout. Yoga gives you rows, columns, wrapping and absolute positioning, so spacing and alignment follow a model most React developers already know instead of a PDF-specific coordinate system.
  • Richer content than plain text. Custom fonts, images, SVG, form fields, hyphenation and page-break control are part of the rendering surface.
  • Flexible output. The same document can render to a file, a stream or a blob, in Node or directly in the client.

Where it fits

It suits teams already working in React who need generated documents: invoices, reports, tickets, certificates or downloadable summaries. Because the layout language is familiar, a developer can often build a first document quickly without learning a separate PDF templating system.

The trade-off is that you are working within react-pdf's component and style model, not full PDF or HTML/CSS fidelity. If your requirement is pixel-exact reproduction of an existing web page, or heavy print-publishing features, the constraints of the flexbox-based layout may get in the way. For structured, data-driven documents, that same constraint is usually an advantage.

A concrete next step

Install it and render a minimal document in the environment you actually need:

npm install @react-pdf/renderer

Then decide based on your target: if the PDF must be produced on demand in the browser (for example, a user clicks "Download invoice"), test the client path; if it must be generated in a job or API response, test the Node path. Start with the official docs and the playground at react-pdf to see the component set before committing to it.

How do I install and start using react-pdf in a React project?

Install the renderer package, import its components, and render a <Document> that contains one or more <Page> elements. That is the whole mental model: react-pdf is a React renderer for PDF files, so you compose PDFs with components rather than drawing coordinates.

npm install @react-pdf/renderer

A minimal document looks like this:

import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer';

const styles = StyleSheet.create({
  page: { padding: 32, flexDirection: 'column' },
  heading: { fontSize: 18, marginBottom: 12 },
  row: { flexDirection: 'row', justifyContent: 'space-between' },
});

const Invoice = () => (
  <Document>
    <Page size="A4" style={styles.page}>
      <Text style={styles.heading}>Invoice</Text>
      <View style={styles.row}>
        <Text>Item</Text>
        <Text>Amount</Text>
      </View>
    </Page>
  </Document>
);

Where the PDF actually goes

The same document can be produced in the browser or on the server, and you choose the output shape at the point of use. This is the part that most often trips people up, because "react-pdf" is used for two different jobs.

Output Typical use Where it runs
Blob Download button or preview in the client Browser
Stream Pipe into an HTTP response Node server
File Save to disk, e.g. in a script or job Node server

In the browser, wrap the document in a download or blob provider component rather than expecting a raw PDF object back. On the server, render to a stream and pipe it to the response so you never hold the whole file in memory.

Practical starting steps

  1. Build one page with static content first and confirm it renders before adding data.
  2. Move styles into StyleSheet.create early; inline style objects are harder to reuse across pages.
  3. Add dynamic data by passing props into your document component, exactly as you would with any React component.
  4. Test pagination with real content lengths, not placeholder text.
  5. Only then add fonts, images or SVG.

Things to decide before you commit

  • Layout engine. Flexbox is the layout model here, including rows, columns, wrapping and absolute positioning, so existing CSS knowledge transfers but not existing CSS. Plain CSS files, media queries and browser layout quirks do not apply.
  • Rendering location. Client-side rendering keeps your server simple but shifts work to the user's device and makes large documents feel slow. Server-side rendering is better for batch jobs, emails and anything you want to cache, but it needs a Node environment.
  • Beyond text. Custom fonts, images, SVG, form fields, hyphenation and page-break control are supported, which covers invoices, reports and certificates comfortably. If you need complex charts or heavy print production features, check whether the output matches what your design tool produces.

A concrete next step

Pick the smallest real document you already produce, such as a one-page receipt, and rebuild it as a document component with two or three props. Render it as a blob in a button click handler. If that works end to end, the rest is styling and data plumbing.

For component APIs and server examples, work through the official documentation at react-pdf. If your team already renders PDFs in Node with a different library, PDFKit is the lower-level alternative worth comparing, since it gives you imperative drawing rather than a component tree.

Can react-pdf generate PDFs on the server as well as in the browser?

Yes. react-pdf is explicitly built to render the same document in both environments: the page states that a document can render "to a file, a stream or a blob — in Node or straight in the client." So server-side generation is a first-class use case, not a workaround.

What that means in practice

  • Server: use it for scheduled reports, invoices, emails or batch jobs where the PDF must be created without a user's browser. The stream output is convenient for piping into an HTTP response or writing to storage.
  • Browser: use it when the user should preview or download immediately, or when the data already lives client-side and you want to avoid a round trip.
  • Same code path: because the layout engine is shared, a document component written once can be reused on both sides. That is the main practical benefit — you maintain one template rather than two.

Trade-offs to decide between them

Consideration Server Browser
Works without a user session Yes No
Data access Direct to database or internal APIs Only what the client already has
Compute cost Uses server CPU/memory per render Offloads work to the user's machine
Delivery Stream, file or blob to send onward Immediate download or preview
Fonts and assets Must be available server-side Loaded in the client

A concrete scenario: a monthly billing statement can be generated server-side and streamed into an email attachment, while the same template powers an in-app "Download PDF" button. One component, two delivery routes.

Next step

Install with npm install @react-pdf/renderer, then confirm your target environment — Node for server rendering, or a bundler-based client app — before structuring the document. If you want to test layout quickly without wiring either one up, the project's playground is the fastest way to iterate. See react-pdf for the current documentation.

How does react-pdf handle layout and styling compared to HTML and CSS?

react-pdf borrows the mental model of CSS but not the browser's rendering engine. You write components (Document, Page, View, Text, Image) and style them with JavaScript objects, using a Flexbox layout engine (Yoga) rather than the full CSS cascade.

What carries over from CSS

  • Flexbox as the default layout model. Rows, columns, wrapping, and absolute positioning all work, so if you already think in flexDirection, justifyContent, and alignItems, the transition is short.
  • Familiar property names. Spacing, borders, typography, and color properties look like their CSS counterparts, applied via a StyleSheet.create() object.
  • Component composition instead of selectors. Where CSS targets elements with class names, react-pdf nests components and passes styles down.

What does not carry over

HTML/CSS react-pdf
Block/inline flow, floats, grid Flexbox only
Stylesheets, classes, cascade, inheritance quirks Style objects and arrays; explicit inheritance
Units like %, em, rem, vh Numeric points; percentage support is limited
@media queries, pseudo-classes None — output is a fixed-size page
Browser text reflow Explicit page-break control and hyphenation

The key difference is that a PDF page has fixed dimensions. There is no viewport to resize into, so responsive design becomes pagination design: you decide where content breaks rather than letting text reflow.

Practical consequences

Debugging shifts from DevTools to the playground and print output. Text that overflows a page will not silently reflow the way a browser would; you manage it with page-break rules and hyphenation. Fonts must be registered explicitly rather than inherited from the system. On the plus side, the same document definition can render to a file, stream, or blob in Node or in the browser, which is unusual for PDF tooling.

Next step: if you have an existing React component tree styled with Flexbox, try porting one screen's layout into a single Page and render it in the playground at react-pdf to see where your CSS assumptions break. For broader context on generating PDFs from web content, MDN Web Docs documents the underlying layout concepts.

What advanced features does react-pdf support, such as custom fonts, images, and form fields?

react-pdf's advanced features cluster around three areas: layout control, rich content, and document interactivity. According to its own documentation, it supports custom fonts, images, SVG, form fields, hyphenation, and page-break control beyond plain text. Layout uses Yoga, which brings flexbox to PDF pages, including rows, columns, wrapping, and absolute positioning—so you can reuse mental models from web layout rather than learning a PDF-specific coordinate system.

What each feature is good for

  • Custom fonts: Embed brand or multilingual typefaces. Practical criterion: subset and test file size, since embedding large families increases output size.
  • Images and SVG: Logos, charts, and vector diagrams. SVG is the better choice for anything that must stay sharp when scaled.
  • Form fields: Fillable fields suit invoices, onboarding packets, and internal forms that recipients complete before returning.
  • Hyphenation and page-break control: These matter most for long, text-heavy documents where orphaned headings or awkward gaps undermine readability.
  • Browser and server rendering: The same document can render to a file, stream, or blob in Node or directly in the client. If you generate on the server, you avoid shipping layout logic to users; if you generate in the browser, you can preview instantly without a round trip.

A concrete scenario: a small team building invoice generation could define one document component, render it server-side to a stream for emailing, and reuse the same component in a browser preview. Form fields would only be worth adding if customers need to edit before submitting.

For comparison, PDFKit is a lower-level imperative library often used in Node, while python-pdfkit wraps a different toolchain entirely—useful context if your stack is not React-based.

Next step: open the playground mentioned on the site and test one custom font plus one page break before committing to a document architecture.

How does react-pdf compare to other JavaScript PDF libraries for React applications?

react-pdf (the @react-pdf/renderer package) is best understood as a React renderer that outputs PDF, not a general-purpose PDF toolkit. If your goal is to author documents as React components and render them to a file, stream or blob on either the server or the client, it is a strong fit. If your goal is to read, parse, merge, annotate or fill existing PDFs, it is largely the wrong tool.

Where it differs from typical JavaScript PDF libraries

Most JavaScript PDF libraries fall into one of three camps, and the trade-off is mostly about authoring model versus document manipulation.

Camp Typical examples Authoring model Best for
Declarative React renderer react-pdf (react-pdf) JSX components, flexbox layout Generating new documents from app data
Imperative drawing API pdfkit, jspdf Canvas-like x/y coordinates, manual flow Fine-grained control, simple documents
PDF manipulation / parsing pdf-lib, pdfjs (PDF.js) Load and edit existing files Merging, splitting, form filling, extraction

The distinguishing feature of react-pdf is its layout engine: Yoga brings flexbox to the page, so rows, columns, wrapping and absolute positioning behave like the CSS you already write. The imperative libraries generally make you compute positions and handle page breaks yourself. The page evidence also lists custom fonts, images, SVG, form fields, hyphenation and page-break control, which covers most of what a report, invoice or certificate generator needs.

When it is the right choice

  • You already build your UI in React and want documents defined in the same mental model.
  • You need the same document to render server-side (for email attachments or batch jobs) and client-side (for instant download), which the project explicitly supports.
  • Your layout maps naturally to flexbox: headers, repeating rows, tables, footers.

When to look elsewhere

  • You must read or modify an existing PDF — reach for pdf-lib or PDF.js instead.
  • You need pixel-perfect, absolutely positioned output with precise typographic control; an imperative API may be less friction than fighting a layout engine.
  • You want a drag-and-drop visual designer rather than code.

A practical decision criterion: if the document is derived from data you control, react-pdf fits; if the document already exists, it does not.

A concrete next step: take one real template — say a monthly invoice — and build it in the react-pdf playground before committing. If the flexbox model expresses your table and page breaks without hacks, the library will scale with your app; if you find yourself fighting the layout for every element, an imperative library like pdfkit will cost you less in the long run.

Related questions

More questions →
How do I get started with react-pdf?

Install @react-pdf/renderer with npm, then build a document out of React components and render it to a file, a stream, or a blob — the same document works in Node or in the browser. That is the whole workflow react-pdf is built around: you describe the PDF with the layout primitives you already use in React, and the renderer produces the actual PDF.

This guide covers the install, a minimal working document, the three render targets, and the points where people usually get stuck.

What react-pdf actually is

react-pdf is a React renderer for creating PDF files on the browser and server. It is not a PDF viewer and not a wrapper around an existing PDF — you author the document in JSX and it renders out as a PDF.

Two things make it feel familiar:

  • Layout you already know. Yoga brings flexbox to the page, so rows, columns, wrapping, and absolute positioning behave the way they do in React Native-style layout.
  • Beyond text. Custom fonts, images, SVG, form fields, hyphenation, and page-break control are all supported.

Install

npm install @react-pdf/renderer

That single package is the entry point. The official docs and the Playground are the two places to look next — the Playground lets you edit a document and see the output without setting up a project.

Write your first document

A react-pdf document is a tree of components. The core ones you need for a first pass:

Component Role
Document Root of the PDF
Page A single page; holds size and style
View A layout container (the flexbox box)
Text Any text content

A minimal document looks like this:

import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer';

const styles = StyleSheet.create({
  page: { padding: 30 },
  row: { flexDirection: 'row' },
  label: { width: 100 },
});

const Invoice = () => (
  <Document>
    <Page size="A4" style={styles.page}>
      <View style={styles.row}>
        <Text style={styles.label}>Invoice</Text>
        <Text>#001</Text>
      </View>
    </Page>
  </Document>
);

Two things to notice:

  • Styles are not CSS. StyleSheet.create takes a subset of CSS expressed as objects. Flexbox properties work; many web-only properties do not.
  • Text must live inside Text. You cannot drop a raw string into a View and expect it to render.

Render it

The same document renders to a file, a stream, or a blob — in Node or straight in the client. Which one you pick depends on where the PDF is going.

On the server (Node)

Use renderToFile when you want a file on disk, or renderToStream when you want to pipe the PDF into an HTTP response:

import { renderToFile } from '@react-pdf/renderer';
import Invoice from './Invoice';

await renderToFile(<Invoice />, './invoice.pdf');

Expected result: invoice.pdf appears at the given path. For an API endpoint, renderToStream lets you send the bytes directly to the client without writing to disk first.

In the browser

Use PDFDownloadLink for a download button, or usePDF when you want the blob and control the timing yourself:

import { PDFDownloadLink } from '@react-pdf/renderer';
import Invoice from './Invoice';

<PDFDownloadLink document={<Invoice />} fileName="invoice.pdf">
  {({ loading }) => (loading ? 'Preparing…' : 'Download invoice')}
</PDFDownloadLink>

Expected result: clicking the link downloads invoice.pdf. The loading flag matters — rendering is asynchronous, so the link is not ready on first paint.

Verify it worked

  • Server: check the file exists and opens in a PDF reader. If you used a stream, confirm the response has the right content type and the browser renders it inline rather than downloading garbage.
  • Browser: click the link and open the downloaded file. If the button never leaves the loading state, the document threw during render — check the console.

Common sticking points

  • Assuming web CSS carries over. Flexbox works; a lot of everything else does not. Build layout with View and flex properties rather than reaching for margins and floats.
  • Putting text outside Text. Raw strings in a View will not render.
  • Forgetting the render is async. In the browser, handle the loading state from PDFDownloadLink or usePDF; on the server, await the render call.
  • Fonts. Custom fonts are supported, but you have to register them before they appear — a missing font shows up as fallback text, not an error.
  • Page breaks. Long content does not always break where you want. Page-break control is available, so use it rather than fighting the default flow.

Where to go next

Start in the Playground to iterate on layout without a build step, then move the document into your app. The docs cover the component set, styling rules, and the rendering APIs in more depth than any single example can.

PDF Invoices in Legal Billing: What to Include and When to Use Them

A PDF invoice in legal billing is a fixed-format document that presents the fees and costs owed on a matter in a layout that looks the same on every device. It is the digital equivalent of a printed bill: readable, portable, and easy to attach to an email or upload to a client portal. Its main limitation is that it is not machine-readable in the way a LEDES file is, so a client's e-billing system cannot automatically ingest it. PDF works best for flat-fee matters, small or one-off engagements, and clients who do not run an automated billing platform.

What "PDF" means in a legal billing context

When a billing tool offers to send an invoice "in PDF," it is generating a rendered document rather than a structured data file. The distinction matters:

  • PDF is a presentation format. A human reads it. Line items, totals, and matter details appear as text and tables on a page.
  • LEDES (Legal Electronic Data Exchange Standard) is a structured, delimited text format. An e-billing system parses it, validates it against outside counsel guidelines, and routes it for review.
  • Email delivery is a transport method, not a format. You can email a PDF, email a LEDES file, or email a link to an online invoice.

These three are often confused because a single invoice can combine them: a LEDES file delivered by email, or a PDF attached to an email. The format is what the client's systems can read; the delivery method is how it arrives.

When a PDF invoice is the right choice

PDF is usually appropriate when the client does not require electronic submission through a billing platform. Common scenarios:

  • Flat-fee and fixed-price matters. When the invoice is one or two lines, a structured file adds no value.
  • Small businesses and individuals. Clients without an accounts payable system can open a PDF and pay from it.
  • Retainers and replenishment requests. A simple statement of the retainer balance is easy to read as a PDF.
  • Pro bono or courtesy bills. Where no formal e-billing review applies.
  • Backup documentation. Even when a LEDES file is submitted, a PDF is often attached for the reviewer's convenience.

If the client has outside counsel guidelines requiring LEDES submission, a PDF alone will typically be rejected or returned for manual entry. Check the client's billing requirements before choosing the format.

PDF versus LEDES versus emailed invoice: a quick comparison

Factor PDF LEDES Email (as delivery)
Machine-readable No Yes N/A
Accepted by e-billing platforms Rarely Yes Depends on attachment
Setup effort Low Higher (mapping fields) Low
Best for Flat fees, small clients, backup Corporate and insurer clients Any format
Risk Manual re-entry by client Format rejection if fields are wrong Lost or filtered messages

Core elements of a compliant legal PDF invoice

A PDF invoice should stand on its own. If a client's AP department picks it up with no context, it should still answer who, what, when, and how much.

Firm and client identification

  • Firm name, address, and contact details
  • Tax or VAT identification number where applicable
  • Client name and billing contact
  • Invoice number and invoice date
  • Client matter number or reference

Matter and timekeeper detail

  • Matter name and description
  • For each timekeeper: name, initials, and billing rate
  • Time entries with date, narrative description, and time recorded in tenths of an hour
  • Clear separation of fee earners if rates differ

Fees, expenses, and totals

  • Fees subtotal
  • Disbursements and expenses, itemized with dates
  • Taxes applied
  • Prior payments, credits, or trust retainer applied
  • Total amount due and currency

Payment terms

  • Due date and payment window
  • Accepted payment methods
  • Remittance details or a payment link
  • Late-payment terms if the engagement letter specifies them

A useful test: hand the PDF to someone who has never seen the matter and ask them to confirm the amount due and the period covered. If they hesitate, the invoice is missing something.

Practical limitations to plan around

PDF invoices shift work to the recipient. Someone at the client has to read the document and key the data into their system, which introduces delay and transcription errors. PDFs also cannot be validated against billing guidelines automatically, so a reviewer may reject a line item that a LEDES rule would have caught before submission.

Two habits reduce the friction:

  1. Send a consistent template. Clients learn where to find the total, the matter number, and the payment terms.
  2. Keep a LEDES version in reserve. If a client later adopts an e-billing platform, you can convert rather than rebuild.

Choosing between PDF, LEDES, and email delivery

Work from the client's requirements backward:

  • Does the client mandate LEDES submission? If yes, PDF is a supplement, not a substitute.
  • Is the matter flat-fee or very small? PDF is usually sufficient.
  • Does the client have no billing system? PDF delivered by email or portal is the simplest path.
  • Is the invoice complex with many timekeepers and expenses? A structured format reduces disputes, even if the client accepts PDF.

When in doubt, ask the client's billing contact which format they prefer and whether a PDF attachment is acceptable alongside any required file. That one question prevents most rejected invoices.

Easy Legal Billing supports sending or scheduling invoices in LEDES, email, or PDF formats, which lets you match the format to each client's requirements rather than forcing one approach across every matter.

Can react-pdf Run in Both the Browser and on the Server?

Yes. react-pdf is a React renderer for creating PDF files, and the same document can render in Node or directly in the client. According to the project's own description, it renders "to a file, a stream or a blob — in Node or straight in the client." That means you can write one document component and produce PDFs on either side, choosing the output form that fits where the code runs.

What "browser and server" actually means

The key point is that react-pdf is not split into two separate libraries with different APIs. It is a renderer: you describe a document with React components, and the renderer turns that description into PDF output. The environment (Node vs. browser) determines which output forms are practical, not how you write the document.

Environment Typical output Where the work happens
Server (Node) File or stream On your server, often in a request handler or background job
Browser (client) Blob (and downloads) In the user's browser, no server round trip required

The source material lists file, stream, and blob as the output forms and states the same document renders to them in Node or in the client. It does not document per-environment API differences, so treat the component code as shared and the output handling as the part that changes.

Why this matters for choosing react-pdf

If you need PDF generation in only one place, the dual-environment support is a convenience. If you need it in both, it removes a common source of duplication: you avoid maintaining one document definition for the server and a different one for the client.

Concrete cases where both sides are useful:

  • Server-side for consistency and control. Generate invoices, reports, or receipts in a Node service so every user gets the same output and the logic stays off the client.
  • Client-side for immediacy and privacy. Produce a PDF in the browser when the user should get it instantly, or when the data should not leave the device.
  • Both, for the same document. Preview or export in the browser, then regenerate the identical document on the server for archival or emailing.

The "same document" claim is the part worth verifying in your own setup: shared components are the promise, but fonts, images, and data sources still need to be available in whichever environment renders.

What the renderer supports beyond plain text

The project highlights three capability areas, and they apply regardless of environment:

  • Layout you already know. Yoga brings flexbox to the page, including rows, columns, wrapping, and absolute positioning. If you have written flexbox in React for the web, the mental model carries over.
  • Beyond text. Custom fonts, images, SVG, form fields, hyphenation, and page-break control.
  • Output flexibility. File, stream, or blob, as noted above.

For a deeper look at layout behavior, see the related question on how layout works in react-pdf; for the full list of renderable content, see what react-pdf can render beyond text.

Getting started

The documented install command is:

npm install @react-pdf/renderer

From there, the project points to two entry points: a getting-started path and an interactive playground. The playground is the faster way to confirm that a document renders the way you expect before wiring it into a server route or a client component.

A practical sequence:

  1. Install @react-pdf/renderer.
  2. Build a minimal document component and render it in the playground to check layout and fonts.
  3. Move that same component into your target environment.
  4. Choose the output form for that environment — stream or file on the server, blob in the browser.

Common sticking points

  • Fonts and images must resolve where you render. A font or image path that works in the browser may not resolve in Node, and vice versa. Confirm assets are reachable in each environment you target.
  • Output handling differs even when the document does not. Writing a stream to a response and triggering a blob download are different tasks; plan for both if you support both environments.
  • Don't assume pricing or hosting details. The source material describes the renderer and its capabilities; it does not state pricing, so check the project's own pages if cost matters to your decision.

The short version: react-pdf is designed so the same React document can render on the server or in the browser, with file, stream, and blob as output options. If your requirement is "generate this PDF in more than one place without rewriting it," that is exactly the case it targets.

What is react-pdf?

react-pdf is a React renderer for creating PDF files, and it works both in the browser and on the server. You describe a document with React components, and the same document can be rendered to a file, a stream, or a blob — in Node or directly in the client. It fits projects that already use React and want PDF generation to live in the same component model as the rest of the app.

How it works

The core idea is that a PDF document is just another React tree. You compose primitives like Document, Page, and View instead of writing imperative drawing calls, and react-pdf translates that tree into PDF output.

The same document definition is portable across environments:

  • Server (Node): render to a file or a stream, useful for generating invoices, reports, or exports in a backend job.
  • Browser (client): render to a blob, useful for letting a user download a PDF without a round trip to the server.

Because the document is described once, you avoid maintaining separate code paths for server-side and client-side generation.

Layout you already know

react-pdf uses Yoga to bring flexbox to the page. If you have written CSS flexbox, the mental model carries over:

  • rows and columns
  • wrapping
  • absolute positioning

This matters because PDF layout is normally a different discipline from web layout. Here, the layout vocabulary is the one React developers already use, which shortens the gap between "I know how to build this screen" and "I know how to build this page."

Beyond text

A PDF renderer is only useful if it handles more than paragraphs. react-pdf supports:

  • custom fonts
  • images
  • SVG
  • form fields
  • hyphenation
  • page-break control

Page-break control and hyphenation are worth calling out, because they are the details that separate a usable generated document from one that looks machine-made. Form fields matter if the output needs to be filled in after generation.

Getting started

Install the renderer:

npm install @react-pdf/renderer

From there, the documented paths are the docs and the playground. The playground is the faster way to confirm whether the layout model matches what you need before committing to it in a project.

When react-pdf is a good fit

Choose it when:

  • your project is already React-based and you want one component model for UI and PDF
  • you need the same document to render on the server and in the browser
  • you need flexbox-style layout rather than manual coordinate placement
  • you need fonts, images, SVG, form fields, hyphenation, or page-break control

Look elsewhere when you need to manipulate or extract content from existing PDFs — react-pdf is a renderer for creating PDF files, not a general PDF editing toolkit.

How Does Layout Work in react-pdf?

react-pdf uses Yoga to bring flexbox layout to PDF pages, so you position elements with the same mental model you already use for CSS: rows, columns, wrapping, and absolute positioning. If you are comfortable with flexbox in the browser, the main adjustment is that you are laying out fixed-size pages rather than a scrolling viewport, and you build the structure with React components instead of HTML tags.

The layout engine: Yoga, not the browser

react-pdf does not run your document through a browser rendering engine. It uses Yoga, a cross-platform layout engine that implements flexbox, to compute positions and sizes. That has two practical consequences:

  • Flexbox is the primary layout tool. You get flexDirection, justifyContent, alignItems, flexWrap, flex, and related properties on View components.
  • There is no CSS cascade or stylesheet. Styles are JavaScript objects passed to a style prop, and they are resolved per component rather than inherited through a global cascade.

Because the same document definition renders to a file, a stream, or a blob — in Node or in the client — the layout result is consistent across server and browser, which matters when you generate the same invoice or report in both places.

Building a page structure with React components

The layout primitives are React components, not HTML elements:

Component Role in layout
Document Root container; holds page-level metadata
Page A fixed-size canvas; you set size and style here
View The flex container/box — your main layout building block
Text Text content, which must live inside a Text or View context

A minimal structure looks like this:

import { Document, Page, View, Text, StyleSheet } from '@react-pdf/renderer';

const styles = StyleSheet.create({
  page: { flexDirection: 'column', padding: 30 },
  row: { flexDirection: 'row', justifyContent: 'space-between' },
  column: { flexGrow: 1, flexBasis: 0 },
});

const Invoice = () => (
  <Document>
    <Page size="A4" style={styles.page}>
      <View style={styles.row}>
        <View style={styles.column}><Text>From</Text></View>
        <View style={styles.column}><Text>To</Text></View>
      </View>
    </Page>
  </Document>
);

The input is the component tree plus the style objects; the action is rendering; the expected result is a laid-out page where the two columns split the available width evenly. Note that flexDirection defaults to column in react-pdf, unlike the browser default of row — a common source of surprise when porting CSS.

What carries over from CSS flexbox

  • Rows and columns: flexDirection: 'row' | 'column' controls the main axis.
  • Distribution: justifyContent and alignItems behave as you expect along the main and cross axes.
  • Wrapping: flexWrap: 'wrap' lets children flow onto multiple lines.
  • Absolute positioning: position: 'absolute' with top, left, right, bottom takes an element out of flow — useful for headers, footers, and watermarks.
  • Sizing: width, height, flexGrow, flexShrink, and flexBasis work on View boxes.

Where it differs from the browser

  • No scrolling viewport. A Page is a fixed canvas. Content that overflows does not scroll; you control it with page breaks.
  • Page-break control is explicit. The docs list page-break control as a feature, so you manage where content splits rather than relying on the browser.
  • Units and defaults differ. Sizes are in points, and as noted, the default flex direction is column.
  • Text is special. Text must be wrapped in Text components; you cannot drop raw strings into a View and expect them to lay out like inline HTML.

Beyond boxes: fonts, images, and SVG

Layout is not only about boxes. The renderer supports custom fonts, images, SVG, form fields, and hyphenation, all of which participate in the same flexbox flow. An image inside a View with flexGrow will size according to the flex rules, and hyphenation affects how text wraps inside its container — so text-heavy layouts benefit from testing with your actual font and content length.

A practical way to verify layout

  1. Install the renderer: npm install @react-pdf/renderer.
  2. Build a small document with one Page and a couple of nested View rows.
  3. Render it to a file or blob and open the result.
  4. Adjust flexDirection, justifyContent, and flexBasis until the boxes land where you want.

The playground linked from the site is the fastest loop for this, since you can change styles and see the page without wiring up a full build.

If your goal is a document whose structure mirrors a familiar CSS flexbox layout — rows, columns, wrapping, absolute overlays — react-pdf is a direct fit. If you need a scrolling, reflowing web page rather than fixed pages, or you depend on the full CSS cascade, flexbox alone will not cover that, and you should treat the layout model as a constrained subset rather than a browser equivalent.

Website Overview

An established domain and managed infrastructure suggest continuity of operations and may support dependable delivery, although neither guarantees service quality.

Domain and Registration

Registered in 2018, this domain has about 8 years of history. That suggests continuity, although ownership and purpose may have changed. Transfer-protection status is present, helping reduce the risk of unauthorized domain transfers. The domain uses the common .org extension, which is not an independent safety signal.

DNS and Email

The lowest TTL is 60 seconds, supporting rapid record changes at the cost of more frequent lookups. Nameservers are provided by vercel-dns.com, indicating managed DNS hosting. CAA records restrict which certificate authorities are authorized to issue certificates. No CNAME was found; the observed records resolve directly to addresses. No MX record was found. A conventional explicit inbound-mail route is not configured.

TLS and Certificates

The certificate uses an RSA 2048-bit public key, offering broad client compatibility. The server supplied a complete certificate chain. No organization name is present in the certificate; the available fields are consistent with domain validation. The certificate was issued by Let's Encrypt, commonly associated with automated certificate services. The certificate's total validity is about 89 days, consistent with a short renewal cycle.

HTTP and Browser Security

X-Powered-By exposes backend information: Next.js. The response lacks these common security headers: CSP, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, clickjacking protection. No obvious internal addresses or debug information were found in the headers. The Server header contains the custom value Vercel. No explicit CDN or WAF marker was found in the response headers.

Technology Stack Analysis

The public page identifies Next.js, Vercel without precise versions, leaving fewer clues for version-specific scanning.

Search and Social Sharing

No homepage canonical URL was detected. If duplicate URLs exist, consolidation may be less explicit. Twitter Card metadata is configured. The title has 33 characters, within a common display range. A meta description is present, with 64 characters. The observed directives allow indexing and link following.

Hosting and Email

DNSvercel-dns.com
HostingVercel
EmailUnknown
Approximate IP geolocation (inferred; a CDN or proxy may differ from the origin server) United States flagUnited States Inferred 66.33.60.130

Registration details

RDAP / WHOIS

RegistrarName.com, Inc.
Registered2018-08-11
Expires2027-08-11
Domain statusclient transfer prohibited
Nameserversns1.vercel-dns.com、ns2.vercel-dns.com
DNSSECunsigned

DNS records

DNS

TypeNameValueTTLPriority
Areact-pdf.org66.33.60.1301800—
Areact-pdf.org76.76.21.2411800—
NSreact-pdf.orgns1.vercel-dns.com86400—
NSreact-pdf.orgns2.vercel-dns.com86400—
CAAreact-pdf.org0 issue "letsencrypt.org"60—
CAAreact-pdf.org0 issue "pki.goog"60—
CAAreact-pdf.org0 issue "sectigo.com"60—

TLS and certificates

TLS / SSL

AssessmentNormal configuration
Supported protocolsTLSv1.2、TLSv1.3
Negotiated protocolTLSv1.3
Certificate subject*.react-pdf.org
IssuerLet's Encrypt
Valid until2027-01-01T21:24 · Remaining when checked: 89 days
Verification detailsCertificate trust: Passed · Hostname match: Passed

HTTP response headers

HTTP

HeaderValue
content-typetext/html; charset=utf-8
cache-controlpublic, max-age=0, must-revalidate
serverVercel
strict-transport-securitymax-age=63072000

Identified technologies

Next.jsVercel

Pages, Search and Sharing

Meta descriptionReact renderer for creating PDF files on the browser and server.
Canonical URLNot detected
LanguageEnglish (default)
Twitter Cardsummary_large_image
All bots 1 allowed · 0 disallowed
  • Allow/

User reviews (0)

  • No reviews yet.