react-exe

Render React components from code strings directly in the browser — no bundler, no build step. TypeScript and JSX compile in milliseconds, npm imports resolve automatically from CDN, and previews run in an isolated iframe with optional Tailwind CSS.

Install

npm install react-exe

Works with React 18 and 19. No bundler configuration needed.

Quick start

import { CodeExecutor } from "react-exe";

const code = `
export default function Hello() {
  return <h1 style={{ color: "#667eea" }}>Hello from react-exe!</h1>;
}
`;

export default function App() {
  return <CodeExecutor code={code} />;
}

Features

FeatureDetails
Runtime executionCompiles TypeScript and JSX with Sucrase (about a millisecond per file) and renders the result
Auto CDN resolutionMissing imports load from npm via esm.sh and share your app's React, so hooks and context work
Isolated iframePreviews get their own DOM and styles; set sandbox: false to render inline
Multi-filePass an array of { name, content, isEntry } with relative imports, @/ aliases, CSS and JSON files
Tailwind CSSenableTailwind: true loads Tailwind inside the preview
Your own modulesPass components and libraries via dependencies, including wildcard keys like "@/components/ui/*"
SmallAbout 55 KB gzipped

Live examples

The playground below shows react-exe running in real time. Try the examples to see the CodeExecutor in action — then head to the docs to learn how each feature works.

Documentation

  • Getting started — Install, first render, Tailwind, npm packages, multi-file
  • API reference — CodeExecutor props, config options, multi-file format
Loading playground…