Quickstart
This guide walks you through creating a Press.js document project from scratch, rendering it to PDF, and previewing the result.
Prerequisites
Section titled “Prerequisites”- Node.js >= 22
- pnpm, npm, or yarn
- Chromium installed (the Playwright renderer will download its own if none is available)
Create a project
Section titled “Create a project”Start with a Vite + TypeScript template for your framework of choice.
npm create vite@latest my-press-report -- --template react-tscd my-press-reportnpm install @press-js/reactnpm create vite@latest my-press-report -- --template vue-tscd my-press-reportnpm install @press-js/vueThen install the Press.js CLI globally so the press command is available in your shell:
npm install --global @press-js/cliCreate your first document
Section titled “Create your first document”Replace the default src/App.tsx (or src/App.vue) with a basic Press.js document.
import { Page, Header, Footer, PageNumber, TotalPages, usePressReady,} from "@press-js/react";
function App() { usePressReady();
return ( <Page type="A4" orientation="portrait" margin="20mm"> <Header> <div style={{ textAlign: "right", fontSize: "9pt", color: "#666" }}> Press.js Report </div> </Header>
<Footer> <div style={{ textAlign: "center", fontSize: "9pt", color: "#666" }}> Page <PageNumber /> of <TotalPages /> </div> </Footer>
<h1>Hello, Press.js</h1> <p> This document was built with React. Every element here is standard HTML and CSS — no proprietary layout APIs needed. </p>
<table> <thead> <tr> <th>Feature</th> <th>Status</th> </tr> </thead> <tbody> <tr> <td>Headers & Footers</td> <td>✓</td> </tr> <tr> <td>Auto-pagination</td> <td>✓</td> </tr> <tr> <td>Page numbers</td> <td>✓</td> </tr> </tbody> </table> </Page> );}
export default App;<script setup lang="ts"> import { Page, Header, Footer, PageNumber, TotalPages, usePressReady, } from "@press-js/vue";
usePressReady();</script>
<template> <Page type="A4" orientation="portrait" margin="20mm"> <header> <div style="text-align: right; font-size: 9pt; color: #666"> Press.js Report </div> </header>
<footer> <div style="text-align: center; font-size: 9pt; color: #666"> Page <PageNumber /> of <TotalPages /> </div> </footer>
<h1>Hello, Press.js</h1> <p> This document was built with Vue. Every element here is standard HTML and CSS — no proprietary layout APIs needed. </p>
<table> <thead> <tr> <th>Feature</th> <th>Status</th> </tr> </thead> <tbody> <tr> <td>Headers & Footers</td> <td>✓</td> </tr> <tr> <td>Auto-pagination</td> <td>✓</td> </tr> <tr> <td>Page numbers</td> <td>✓</td> </tr> </tbody> </table> </Page></template>Configure the build
Section titled “Configure the build”Create a press.toml file in your project root:
workspace = "."
[pdf.report]path = "./dist"route = "/"output = "./artifacts/my-report.pdf"title = "My Press.js Report"build = "npm run build"timeout_ms = 15000Render the PDF
Section titled “Render the PDF”Build your app and render the PDF in one step:
press render reportThe report argument matches the entry name [pdf.report] in press.toml. After rendering completes, you’ll find the PDF at ./artifacts/my-report.pdf.
If you have a single entry in press.toml, you can omit the entry name:
press renderPreview in the browser
Section titled “Preview in the browser”During development, run your app normally:
npm run devWhen you open the page in a browser, Press.js automatically detects it’s not in headless mode and activates the Previewer — a full UI showing the paginated layout with zoom controls, a reload button, and a status bar. The previewer runs the same pagination pipeline that the CLI uses, so what you see is what you’ll get in the PDF.
The previewer only activates in your browser. When Press.js renders the page in headless Chromium, the previewer is skipped and the document is captured directly.
Next steps
Section titled “Next steps”- Read the Philosophy guide for design principles and best practices
- Explore the press.toml Reference for advanced configuration
- Learn about Special Elements like
<KeepTogether>,<PageBreak>, and more