Installation
platex is a two-part system: a compilation service that does the actual LaTeX → PDF work, and a thin client library your app calls. You can also skip the service and compile locally (system TeX Live or the bundled Tectonic binary) — handy for scripts, CLI use, and development.
Install the library
Section titled “Install the library”npm install @nandan-varma/platexThe package exposes three entry points — pick the one that matches your runtime:
| Import from | Runtime | What it’s for |
|---|---|---|
@nandan-varma/platex |
Node.js | compile, createPlatexClient, handleCompileRequest — full library, local-compile fallback included |
@nandan-varma/platex/client |
Anything with fetch (edge, Workers, Bun, Deno, browsers) |
Same client/handler API, remote-only |
@nandan-varma/platex/server |
Node.js | createApp, createCompileRoute — embed the HTTP API into your own server |
See How it works for when to use each.
Set up the service
Section titled “Set up the service”-
Deploy the platex service. It does the actual compilation and runs anywhere Node.js runs — Vercel, Fly.io, Railway, Render, or your own Docker host. On Vercel it bundles the Tectonic engine into the serverless function.
Terminal window git clone https://github.com/nandan-varma/platexcd platexnpx vercel deployYour service is now live at something like
https://platex-xxx.vercel.app. See Deploy the service for the full walkthrough, and Self-hosting with Docker for full TeX Live. -
Point the client at the service. Set
PLATEX_SERVICE_URLin your app’s environment (the Vercel dashboard, or.env.localfor local dev):.env.local PLATEX_SERVICE_URL=https://your-platex-service.vercel.app# PLATEX_API_KEY=... # only if you enabled auth on the serviceBoth
createPlatexClient()and the plaincompile()/handleCompileRequestread these automatically — you never threadprocess.envthrough your own code. -
Compile. That’s the whole setup.
import { compile } from '@nandan-varma/platex';const result = await compile(source); // uses PLATEX_SERVICE_URL
Which engine runs?
Section titled “Which engine runs?”The library auto-selects the engine — you don’t configure this directly. It
resolves serviceUrl from the explicit option, falling back to
PLATEX_SERVICE_URL.
| Mode | When | Engine | Use case |
|---|---|---|---|
| Remote | serviceUrl resolves |
Tectonic (on the service) | Production on Vercel / any edge runtime |
| Local | No serviceUrl, system TeX found |
pdflatex / xelatex / lualatex | Self-hosted or dev with TeX Live |
| Local fallback | No serviceUrl, no system TeX |
Bundled Tectonic binary | Dev / CLI without TeX Live installed |
Develop without any TeX installed
Section titled “Develop without any TeX installed”Skip the service entirely and let the library use the bundled Tectonic binary directly — this is exactly what powers the CLI’s zero-install experience:
node scripts/download-tectonic.mjsThe script downloads Tectonic for your platform (macOS or Linux) and verifies it
against a pinned SHA256 before extracting. After that, any compile() call with
no serviceUrl resolves the bundled binary automatically.
// No serviceUrl → uses the local tectonic binaryconst result = await compile(source);Try the CLI
Section titled “Try the CLI”No project wiring required — the package ships a platex binary that runs the
same pipeline:
npx @nandan-varma/platex main.tex # → main.pdf, no TeX installation required