Created
May 3, 2026 21:51
-
-
Save haggen/42f7e6c6a589088a83e06ae11f456103 to your computer and use it in GitHub Desktop.
Simplest JSX as template on Bun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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