API reference
CodeExecutor
The main rendering component.
import { CodeExecutor } from "react-exe";
<CodeExecutor
code={code} // string | CodeFile[]
config={config} // optional CodeExecutorConfig
/>
Props
| Prop | Type | Description |
|---|
code | string | CodeFile[] | Component source code, or an array of files |
config | CodeExecutorConfig | Optional configuration object |
CodeExecutorConfig
| Property | Type | Default | Description |
|---|
sandbox | boolean | true | Render inside an iframe with its own DOM and styles |
enableTailwind | boolean | false | Load Tailwind CSS for the preview |
dependencies | Record<string, any> | {} | Modules available to the code, keyed by import path. Keys ending in /* match any sub-path |
autoResolvePackage | boolean | true | Load imports that aren't in dependencies from npm via esm.sh |
onError | (error: Error) => void | — | Called for compile, security-pattern, package-loading and render errors |
securityPatterns | RegExp[] | see below | Code matching any pattern is held back until the user clicks "Continue Anyway" |
containerClassName | string | — | Class name for the preview container |
containerStyle | CSSProperties | |