The Node.js SDK is shipped as an NPM package.

npm install -s @onedoc/client


import { Onedoc } from "@onedoc/client";

const onedoc = new Onedoc(process.env.ONEDOC_API_KEY);

const document = {
  html: "<h1>Hello world</h1>",
  assets: [],

const { file, info, error } = await onedoc.render(document);



Constructor for the Onedoc client. Takes an API key as argument.


The render function takes a document object as an argument and returns an object that contains the file or download link to the rendered document.



The document object has the following properties:

htmlstringfalsen/aThe html for your document ( for react, use renderToString)
titlestringtruen/aThe PDF’s title
testbooleantruetrueDetermines whether a document is rendered with a watermark or not. Dev document renderings are free and can be made infinitely many times
savebooleantruefalseDetermines whether a document should be saved temporarily. It is saved for as many days as provided in the expiresIn parameter. It can be downloaded anytime via a download link
expiresInintegertrue1Determines for how long a document should be downloadable. Maximum duration is 90 days. This field is only effective if saveis true
assetsPathString[] | PathBuffer[]truen/aA list of objects {path, content}, where pathis a relative path from which the html should import the asset. content is the Buffer or string content of the asset

Stylesheets should be loaded as assets. In the event where frameworks such as TailwindCss are used, remember to upload the compiled stylesheets.

Returns (promise)

filearrayBuffer | nullThe rendered PDF file.
linkstring | nullThe download link for save = true documents.
infoobject | nullThe render metadata.
errorstring | nullThe render error.

Was this page helpful?