Accurate PDF output
Standard engine flags, multi-pass logic, and rerun heuristics for faithful LaTeX-to-PDF rendering — as accurate as your local TeX toolchain.
@nandan-varma/platex compiles LaTeX to PDF from TypeScript. It works in any
framework that speaks the Fetch API
— Next.js, TanStack Start, Astro, SvelteKit, Remix, Bun, Deno, Cloudflare
Workers — on Node.js or the edge. Nothing is hardcoded: every engine, timeout,
limit, auth token, and retry setting is an option with a sane default and an
env-var fallback.
npm install @nandan-varma/plateximport { compile } from '@nandan-varma/platex';
const result = await compile(source, { serviceUrl: process.env.PLATEX_SERVICE_URL, // omit — read automatically});
if (result.pdf) { // result.pdf is a Buffer — return, save, or stream it}import { createPlatexClient } from '@nandan-varma/platex';
export const platex = createPlatexClient({ timeout: 25_000, retry: 2 });
// anywhereconst result = await platex.compile(source);// app/api/compile/route.ts (Next.js)import { handleCompileRequest } from '@nandan-varma/platex';
export const POST = handleCompileRequest;npx @nandan-varma/platex main.tex # → main.pdf, no TeX install neededplatex main.tex --watch # recompile on saveAccurate PDF output
Standard engine flags, multi-pass logic, and rerun heuristics for faithful LaTeX-to-PDF rendering — as accurate as your local TeX toolchain.
Runs anywhere
Node.js or the edge. Three entry points: a full Node library, an edge-safe remote-only client, and a server factory to embed the API.
Two deployment targets
A remote service for Vercel (bundled Tectonic), or full TeX Live locally / self-hosted — the same library auto-selects.
Structured diagnostics
Errors and warnings parsed from raw TeX logs, with file, line, and category — plus per-pass raw logs for debugging.
A real CLI
The same pipeline as a platex binary — watch mode, extra files,
remote compilation, stdin, and JSON output.
Zero config
Set PLATEX_SERVICE_URL and go. Every option is optional, overridable
per call, per client, or per deployment.
The same handleCompileRequest handler — a standard Request → Response
function — works in every framework. Next.js also gets a dedicated page per
rendering pattern:
compile() runs during the server render; the PDF ships in the initial HTML.fetch.'use server' function.