API reference

CodeExecutor

The main rendering component.

import { CodeExecutor } from "react-exe";

<CodeExecutor
  code={code}       // string | FileObject[]
  config={config}   // optional ExecutorConfig
  key={refreshKey}  // change key to force re-render
/>

Props

PropTypeDescription
codestring | FileObject[]React component source code or array of file objects
configExecutorConfigOptional configuration object

ExecutorConfig

PropertyTypeDefaultDescription
sandboxbooleantrueRender in an isolated iframe sandbox
enableTailwindbooleanfalseInject Tailwind CSS CDN into the sandbox frame
dependenciesRecord<string, unknown>{}Pre-provide npm packages by name
autoResolvePackagebooleantrueAuto-fetch missing imports from CDN
heightstring"100%"Iframe height when sandbox is enabled

FileObject

Used when passing multiple files via the code prop:

PropertyTypeDescription
namestringFile path, e.g. "components/Card.tsx"
contentstringSource code for this file
isEntrybooleanMark the root component file

Notes

  • The code string must export a default React component.
  • React is available as a global inside code strings — no import needed.
  • When sandbox: true, the iframe uses srcdoc with a self-contained HTML document.
  • To force a re-render (e.g. after editing), change the key prop on CodeExecutor.
Loading playground…