An embeddable, browser-based LaTeX editor with real-time PDF preview — Monaco
editor, an in-browser pdfLaTeX engine (WASM), and PDF.js. Documents that need
XeLaTeX or LuaLaTeX (fontspec, unicode-math, CJK, \directlua) are auto-detected;
the full multi-engine pipeline runs through the headless compiler
on the client or a Node server. TeX Live packages stream from a public CDN, so
there's nothing to host.
FastLaTeX is not on npm — install from GitHub. The install ships a prebuilt lib/
bundle, so it works with no build step. monaco-editor and pdfjs-dist are peer
dependencies.
npm install monaco-editor pdfjs-dist
npm install github:corca-ai/fastlatex#mainimport * as pdfjsLib from 'pdfjs-dist'
import { FastLatex } from 'fastlatex'
import 'fastlatex/style.css'
// Worker setup is REQUIRED — see the Integration Guide for the full block.
self.MonacoEnvironment = { /* monaco workers */ }
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.mjs', import.meta.url,
).toString()
const editor = new FastLatex('#editor', '#preview', {
files: { 'main.tex': '\\documentclass{article}\\begin{document}Hi!\\end{document}' },
})
await editor.init()👉 Start here: the Integration Guide has the complete worker
setup and copy-pasteable recipes. A minimal example lives in
examples/embed.html.
| Import | Purpose |
|---|---|
fastlatex |
Full editor + PDF preview SDK. |
fastlatex/headless |
DOM-free compiler (your app owns editor/preview). |
fastlatex/node |
Run the engines under Node (installNodeWorkerHost + FastLatexCompiler). |
fastlatex/lsp |
Monaco-free LaTeX language service core. |
fastlatex/lsp/monaco |
Monaco provider adapter. |
fastlatex/lsp/server |
Transport-agnostic JSON-RPC language server. |
fastlatex/style.css |
Optional built-in UI/viewer styles. |
- Integration Guide — install, worker setup, headless, collaboration, engine selection.
- API Reference — constructor options, methods, events, PdfViewer.
- Architecture — SDK structure, VFS, LSP internals.
- Execution Model — client/server hybrid, pluggable per-stage backends.
- Engine & TeX Live — WASM engines, multi-engine routing, CDN.
- Bibliography · Warmup · Contributing
Contributing to FastLaTeX itself? See AGENTS.md and docs/develop.md.
The built-in LaTeX language server (editor-neutral cores in src/lsp/, with a Monaco adapter) provides:
| Feature | Status |
|---|---|
| Completion (commands, refs, cites, packages, files) | ✅ |
| Hover (commands w/ signature + package, citations) | ✅ |
| Go-to-definition / references / rename | ✅ |
| Document symbols / outline | ✅ |
| Diagnostics + ChkTeX-style linter | ✅ |
| Signature help (argument hints) | ✅ |
Folding ranges (environments, sections, % region) |
✅ |
| Document highlight (occurrences under cursor) | ✅ |
| Workspace symbols (labels/sections/commands) | ✅ via fastlatex/lsp service + LSP server (Monaco has no workspace-symbol UI) |
Code actions (insert ~, add \usepackage, create \label) |
✅ |
Inlay hints (resolved .aux numbers next to \ref) |
✅ |
Document links (\input/\include, \url/\href) |
✅ |
| Semantic tokens (commands, math, comments, verbatim) | ✅ |
Formatting (latexindent-style) |
⏳ planned |