This guide walks you through the fastest path from a blank directory to a rendered PNG. You will install Grafex, scaffold the required files with a single command, and run your first export. The whole process takes less than two minutes.Documentation 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.
Install the
grafex package from npm. The postinstall script will automatically download a headless WebKit browser binary — no extra steps needed.Node.js >= 20.0.0 is required. On Linux, WebKit also needs system dependencies — run
npx playwright install-deps webkit before installing if you are on a Linux machine or CI runner.Run
grafex init to create two files in your current directory: a tsconfig.json pre-configured with the correct JSX compiler options, and a composition.tsx starter file with a working example.If either file already exists it is skipped without error, so it is safe to run
init in an existing project.import type { CompositionConfig } from 'grafex';
export const config: CompositionConfig = {
width: 1200,
height: 630,
};
export default function Composition() {
return (
<div
style={{
width: '100%',
height: '100%',
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white',
fontSize: '64px',
fontWeight: 'bold',
fontFamily: 'system-ui, sans-serif',
}}
>
Hello, Grafex!
</div>
);
}
The
config export sets the canvas size to 1200×630 pixels — the standard Open Graph image dimension. The default-export function is your composition: a regular JSX component that returns the layout you want rendered.Grafex will transpile the file, render it in a headless WebKit page, take a screenshot, and write
output.png to disk. Open the file to see a 1200×630 PNG with a purple gradient and “Hello, Grafex!” centred in white text.Try the live dev server
Once your composition is working, you can start a live preview that re-renders within ~100ms every time you save changes:composition.tsx, the preview updates automatically. Press Ctrl+C to stop the server.
What’s next
TypeScript Setup
Understand the custom JSX runtime and how to configure TypeScript manually if you did not use grafex init.
CLI Reference
Explore all flags for the
export, dev, and init commands.