TheDocumentation 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.
grafex dev command starts a local HTTP server that renders your composition in a headless browser and serves the result as a live-updating preview. Every time you save the composition file, one of its imports, a referenced CSS file, or a local image asset, the server re-renders and pushes the updated image to the browser via Server-Sent Events — no manual refresh needed. Open http://localhost:3000 (or a custom port) to see your composition as it would look when exported.
Usage
Flags
Path to the
.tsx composition file to preview. Short form: -f.Port for the local preview server. Must be an integer between
1 and 65535.Props to pass to the composition’s default export, serialised as a JSON string. The string must be valid JSON.
Pin the preview to a specific named variant defined in
config.variants. When omitted and the composition has variants, the preview defaults to the first variant in the config.variants object. The variant switcher UI in the browser is still available to switch between variants at runtime unless this flag is set.Print the help text and exit. Short form:
-h.Examples
How the dev server works
Start the server and open a browser
grafex dev starts the HTTP server, performs an initial render, and automatically opens http://localhost:<port> in your default browser. The terminal prints a banner with the file name, port, composition dimensions, and initial render time.Edit your composition
Save any watched file and the server re-renders within ~100ms. The browser updates automatically — no reload, no manual action. The terminal logs each change:
Switch variants in the browser (when applicable)
When your composition defines
config.variants, a variant switcher dropdown appears in the preview UI. Selecting a different variant triggers an immediate re-render for that variant. The URL updates to /?variant=<name> so you can bookmark or share the link.File watching
The dev server watches the following files for changes:| File type | What is watched |
|---|---|
| Composition | The .tsx file passed to --file |
| Imports | Every local module imported by the composition (resolved at transpile time) |
| CSS files | Files listed in config.css, resolved relative to the composition |
| Local image assets | src attributes and CSS url() references that point to local files |
All changes are debounced with a ~100ms delay. If you save a file multiple times in quick succession, only one render is triggered after the last save — preventing redundant work during fast edits.
Variant switcher UI
Whenconfig.variants is defined, the preview page renders a dropdown above the composition image:
/?variant=twitter) so refreshing the page or sharing the link preserves the selection.
When
--variant is passed on the command line, the variant is pinned for the entire session. The dropdown still appears in the browser but switching it triggers a fresh render for the requested variant.Tailwind CSS workflow
Run Tailwind’s--watch mode alongside grafex dev for a fully live styling workflow:
concurrently:
styles.css, Grafex detects the CSS change and re-renders within ~100ms — no plugins or extra configuration needed.
Error overlay
If the composition throws an error during render (syntax error, runtime exception, missing module), the preview page shows a full-screen error overlay with the error message instead of crashing the server. Fix the error in your editor, save, and the overlay disappears as soon as the next render succeeds.Global flags
The following flags are available on the top-levelgrafex command, before any subcommand: