API overview

Overview of the DocStudio public API: entry points, the most used functions, options and return types, error handling conventions and where the full reference lives.

The full reference for each entry point is generated from the package's own exports. This page is the map.

Entry point Reference
docstudio Root API
docstudio/core Core API
docstudio/render Render API
docstudio/designer Designer API
docstudio/pdf PDF API
docstudio/server Server API

The functions you will use most

Function Entry Returns
renderDocument(template, data, options?) docstudio { ok, html, diagnostics }
compile({ template, data, ...options }) docstudio/core { ok, tree, diagnostics, meta, trace }
render(tree, options?) docstudio/render HTML with diagnostics
validateTemplateStructure(input, options?) docstudio/core { valid, diagnostics }
printHtml(html, options?) docstudio/pdf A promise that resolves when the print dialog closes
createPdfClient(options) docstudio/pdf A client with render
createPdfService(options) docstudio/server A service with render and close
Designer docstudio/designer A React component

Error handling conventions

  • Functions over JSON input do not throw. They return diagnostics with a code, a severity, a message and a JSON Pointer path.
  • Expression functions are total: invalid input gives an empty value and a diagnostic.
  • The server and storage functions return failure results such as { ok: false, status, diagnostics }.
  • Programmer mistakes, such as a missing required option, can throw.

See diagnostics.

Stability

Only names exported from an entry point are public. Anything else may change at any time. Version 0.2.0 removed designer exports that were internal, as described in the migration guide.

Last updated 2026-12-03