mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
* importstar_ts * tests * run acorn test suite * bench tweaks * test * bun.build tests very incomplete * remove dataurl and base64 loaders from tests since they dont work yet * tests * stuff * stuff * add errors and array of blobs * work so far * docs * requested changes * fix overwrite docs * remove this file
31 lines
700 B
JavaScript
31 lines
700 B
JavaScript
// to run this:
|
|
// NODE_ENV=production bun react-hello-world.jsx
|
|
|
|
// Make sure you're using react-dom@18.3.0 or later.
|
|
// Currently that is available at react-dom@next (which is installed in this repository)
|
|
import { renderToReadableStream } from "react-dom/server";
|
|
const headers = {
|
|
headers: {
|
|
"Content-Type": "text/html",
|
|
},
|
|
};
|
|
|
|
const App = () => (
|
|
<html>
|
|
<body>
|
|
<h1>Hello World</h1>
|
|
<p>This is an example.</p>
|
|
</body>
|
|
</html>
|
|
);
|
|
|
|
const port = Number(process.env.PORT || 3001);
|
|
Bun.serve({
|
|
port,
|
|
async fetch(req) {
|
|
return new Response(await renderToReadableStream(<App />), headers);
|
|
},
|
|
});
|
|
|
|
console.log(`Server running on\n http://localhost:${port}`);
|