Reactwright ships three command-line tools:
| CLI | Package | What it does |
|---|---|---|
reactwright |
reactwright |
Render a .tsx document file to HTML and/or PDF. |
reactwright-md |
@reactwright/markdown |
Render a Markdown (.md) file to HTML and PDF. |
create-reactwright-doc |
create-reactwright-doc |
Scaffold a new document project. |
All three respect Node's standard --help / -h flag and exit
non-zero on error with a message on stderr.
Render a TSX document file through the engine.
reactwright <input.tsx> [--format html,pdf,png] [--out <dir>]The input file must export:
default,Content, orcontent— the content tree (a React component returning<document>…</document>).- Optionally
Templateortemplate— the template component. If omitted, a minimal A4 default template is used.
| Flag | Argument | Default | Description |
|---|---|---|---|
--format |
html|pdf|png |
html |
Comma-separated formats to emit. Repeatable in one flag. |
--out |
<dir> |
./build/reactwright-run |
Output directory. Created if missing. |
Output file names are derived from the input's base name. For
paper.tsx, the outputs are paper.html, paper.pdf, and/or
paper-001.png, paper-002.png, … (PNG mode emits one image per
page).
PDF and PNG rendering shell out to Chromium via puppeteer. Install one of:
npm install puppeteer # bundles its own Chromium
npm install puppeteer-core # uses system Chrome via PUPPETEER_EXECUTABLE_PATHRender to HTML only:
reactwright paper.tsx
# writes build/reactwright-run/paper.htmlRender to HTML and PDF in a custom directory:
reactwright paper.tsx --format html,pdf --out dist
# writes dist/paper.html and dist/paper.pdfRender to per-page PNGs (useful for thumbnails):
reactwright paper.tsx --format png --out previews
# writes previews/paper-001.png, paper-002.png, ...The CLI is a thin wrapper over runExternalFile:
import { runExternalFile } from "reactwright";
const result = await runExternalFile({
inputPath: "./paper.tsx",
outDir: "./dist",
formats: ["html", "pdf"]
});
// result.htmlPath, result.pdfPathRender a Markdown file (with optional YAML frontmatter) through any Reactwright template.
reactwright-md <input.md> [options]The frontmatter template field selects the template; passing
--template= overrides it.
| Flag | Argument | Default | Description |
|---|---|---|---|
--template=<name> |
template flag | essay (or frontmatter value) |
Override the template. essay, ieee, report, etc. |
-o, --output=<path> |
file path | next to the input file | Output base path; both .html and .pdf are written. |
--html-only |
— | off | Skip PDF generation. |
-h, --help |
— | — | Show help and exit. |
Render with the template named in the frontmatter:
reactwright-md paper.md
# writes paper.html and paper.pdf next to paper.mdOverride the template:
reactwright-md paper.md --template=ieeeWrite to a custom location, HTML only:
reactwright-md paper.md -o build/paper.pdf --html-only
# writes build/paper.html; skips PDFAny YAML key is accessible to the chosen template, but two are canonical:
template:— selects the template package (essay→@reactwright/template-essay, etc.).title:,author:— passed to<document>.references:— list of{ key, text }entries that become<ref-entry>blocks at the end of the document.
See the markdown package README for the full Markdown-to-Reactwright mapping table.
Scaffold a new document directory wired to the engine and one of the official templates.
npm create reactwright-doc <name> -- --template=<template>
npx create-reactwright-doc <name> --template=<template>| Flag | Package | Description |
|---|---|---|
essay |
@reactwright/template-essay |
MLA-style academic essay (default). |
ieee |
@reactwright/template-ieee |
IEEE conference paper, two columns. |
ieee-report |
@reactwright/template-ieee-report |
IEEE long-form, single column. |
report |
@reactwright/template-report |
Business / technical report. |
book |
@reactwright/template-book |
Long-form chaptered book. |
letter |
@reactwright/template-letter |
Formal business letter. |
For npm create reactwright-doc my-doc -- --template=essay:
my-doc/
├── package.json deps: reactwright + the chosen template
├── my-doc.tsx starter content + re-exported Template
└── README.md build instructions for this document
The package.json script is
"build": "reactwright my-doc.tsx --format html,pdf --out ." so
npm run build invokes the engine on your TSX file once dependencies
are installed, writing the HTML and PDF alongside the source.
Default (essay):
npm create reactwright-doc thesis-draftConference paper:
npm create reactwright-doc shannon-paper -- --template=ieeeTrade-paperback novel:
npm create reactwright-doc my-novel -- --template=book✓ Created my-doc/
my-doc/
├── package.json
├── my-doc.tsx
└── README.md
Next steps:
cd my-doc
npm install
npm run build
The scaffolder refuses to overwrite an existing directory and exits non-zero with an explanation.