Files
bun.sh/docs/guides/ecosystem/react.md
Colin McDonnell 404b90badc Add ecosystem guides (#3847)
* Add ecosystem guides

* Update titles

* Rename stric

* Add unlink and fetch guides

* Add formdata guide

* Tweak title

* Moar
2023-07-31 12:20:23 -07:00

655 B

name
name
Use React and JSX

React just works with Bun. Bun supports .jsx and .tsx files out of the box. Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.

function Component(props: {message: string}) {
  return (
    <body>
      <h1 style={{color: 'red'}}>{props.message}</h1>
    </body>
  );
}

console.log(<Component message="Hello world!" />);

Bun implements special logging for JSX to make debugging easier.

$ bun run react.tsx
<Component message="Hello world!" />

Refer to Runtime > JSX for complete documentation on configuring JSX.