This project provides an API to render HTML, CSS, JavaScript, and React components as images using Next.js and Playwright. It allows users to pass a component (HTML and CSS, or a React component), JavaScript, CSS/SCSS, and a list of dependencies, and the API will return an image URL after rendering the component.
npm install
npm run dev
http://localhost:3000/api/render
with the appropriate payloadRequest payload:
{
"component": "string",
"css": "string",
"javascript": "string (optional)",
"viewportWidth": "number (optional, default: 640)",
"viewportHeight": "number (optional, default: 640)",
"imageFormat": "string ('jpeg' or 'png', optional, default: 'png')",
"dependencies": "object (optional)"
}
{
"imageUrl": "string"
}