createRenderer(), but can be instantiated directly if needed.
For complete type definitions and interfaces, see the Type
Definitions page.
Methods
getTemplate
Retrieves a template by its unique ID.Parameters
The template ID to look up
Returns
The template definition, or
undefined if not foundrenderToImage
Renders a template to a PNG image buffer. This is the main method for generating OG images.Parameters
The ID of the template to render
Parameters specific to the chosen template, or a function returning a Promise
of parameters. User-provided parameters override shared parameters.
Rendering options
Returns
A promise that resolves to the PNG image buffer
Rendering process
1
Template Lookup
Looks up the template by ID in the internal registry
2
Parameter Merging
Merges shared params with user paramsPriority: Parameters are merged with the following precedence
(highest to lowest):
paramspassed torenderToImage()sharedParamsfrom renderer configuration- Template default parameters
3
Cache Checking
Generates a cache key and checks for cached result
4
Before Render Hook
Calls
beforeRender hook if configured5
Core Rendering
Delegates to the core rendering engine
6
Cache Storage
Caches the generated image
7
After Render Hook
Calls
afterRender hook if configured8
Return Buffer
Returns the PNG buffer