The Grafex library lets you drive image generation directly from Node.js code — no CLI invocation required. ImportDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/andresilva-cc/grafex/llms.txt
Use this file to discover all available pages before exploring further.
render to convert a composition to a buffer, renderAll to process every variant in one call, and close to shut down the shared browser process when you’re finished. The library manages a single headless WebKit (or Chromium) browser instance internally, so all render calls within a session share the same warm browser — no repeated launch overhead.
Installation
npm install via a postinstall script. No extra setup is needed.
Imports
The three core functions cover the full rendering lifecycle:Browser lifecycle
Grafex creates one sharedBrowserManager instance the first time render() or renderAll() is called. That browser process stays alive across all subsequent render calls in the same Node.js process, which avoids the cost of launching a new browser on every image.
You are responsible for calling close() once you are done rendering. Without it, the browser process keeps the Node.js event loop open and your script will not exit cleanly.
After close() is called, the internal reference is cleared. The next call to render() or renderAll() automatically creates a fresh browser instance, so there is no need to manually re-initialize anything.
Function reference
render()
Render a single composition — or one named variant — to a
Buffer.renderAll()
Render every variant defined in
config.variants in a single call, returning a Map keyed by variant name.close()
Shut down the shared browser process and free all resources when you’re done rendering.
Complete example
The script below renders three compositions sequentially, writes each output to disk, then closes the browser. A single browser instance is reused across all threerender calls.