Skip to content

Instantly share code, notes, and snippets.

@haggen
Created May 3, 2026 21:51
Show Gist options
  • Select an option

  • Save haggen/42f7e6c6a589088a83e06ae11f456103 to your computer and use it in GitHub Desktop.

Select an option

Save haggen/42f7e6c6a589088a83e06ae11f456103 to your computer and use it in GitHub Desktop.
Simplest JSX as template on Bun
import type { ReactNode } from "react";
import { renderToReadableStream } from "react-dom/server";
function Page({ children }: { children: ReactNode }) {
return (
<html lang="en-us">
<head>
<meta charSet="utf-8" />
<title>Welcome</title>
</head>
<body>{children}</body>
</html>
);
}
export async function GET() {
const page = (
<Page>
<main>
<h1>Starting page</h1>
</main>
</Page>
);
return new Response(await renderToReadableStream(page), {
headers: { "Content-Type": "text/html" },
});
}
Bun.serve({
routes: {
"/": { GET },
},
fetch() {
return new Response(null, { status: 404 });
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment