> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# Use React and JSX

> How to use React with Bun

Bun has native support for React and JSX, making it easy to build React applications without any build configuration.

## Quick Start

<Steps>
  <Step title="Create a new project">
    ```bash theme={null}
    mkdir my-react-app
    cd my-react-app
    bun init -y
    ```
  </Step>

  <Step title="Install React">
    ```bash theme={null}
    bun add react react-dom
    bun add -d @types/react @types/react-dom
    ```
  </Step>

  <Step title="Create app.tsx">
    ```tsx app.tsx theme={null}
    import React from "react";

    export function App() {
      return (
        <div>
          <h1>Hello from React + Bun!</h1>
        </div>
      );
    }
    ```
  </Step>

  <Step title="Create server.tsx">
    ```tsx server.tsx theme={null}
    import { renderToString } from "react-dom/server";
    import { App } from "./app";

    Bun.serve({
      port: 3000,
      fetch() {
        const html = renderToString(<App />);
        return new Response(
          `<!DOCTYPE html>
          <html>
            <head><title>React + Bun</title></head>
            <body><div id="root">${html}</div></body>
          </html>`,
          { headers: { "Content-Type": "text/html" } }
        );
      },
    });

    console.log("Server running at http://localhost:3000");
    ```
  </Step>

  <Step title="Run the server">
    ```bash theme={null}
    bun run server.tsx
    ```
  </Step>
</Steps>

## JSX Configuration

Bun automatically transforms JSX. Configure it in `tsconfig.json`:

```json tsconfig.json theme={null}
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "react"
  }
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Next.js" icon="triangle" href="/guides/ecosystem/nextjs">
    Build full-stack React apps with Next.js
  </Card>

  <Card title="JSX" icon="code" href="/runtime/jsx">
    Learn about JSX support in Bun
  </Card>
</CardGroup>
