Created
April 29, 2024 20:04
-
-
Save abelcha/57760034cb9794d67a32e1342ad33081 to your computer and use it in GitHub Desktop.
bun run --watch --install auto index.tsx
This file contains 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 'react@^19.0.0-beta' | |
import 'react-dom@^19.0.0-beta' | |
import { renderToReadableStream } from "react-dom/server" | |
const css = ` | |
@font-face { | |
font-family: 'CLIG'; | |
font-style: normal; | |
font-weight: 800; | |
src: url('https://fonts.clig.dev/EditorialNew-Regular.woff2') format('woff2') | |
} | |
* { font-family: 'CLIG'; color: white;font-size: 32px} | |
h1 { font-size: 112px } | |
` | |
function Component(props: { message: string }) { | |
return ( | |
<body style={{ flexDirection: 'column', justifyContent: 'center', alignItems: 'center', display: 'flex', backgroundColor: 'black' }}> | |
<style dangerouslySetInnerHTML={{ __html: css }} /> | |
<h1>{props.message}</h1> | |
<marquee behavior="alternate" loop="1" scrollamount="15" direction="left">...</marquee> | |
</body > | |
); | |
} | |
const server = Bun.serve({ | |
port: 3000, | |
async fetch() { | |
const stream = await renderToReadableStream( | |
<Component message="Memory of the future" />, | |
); | |
return new Response(stream, { | |
headers: { "Content-Type": "text/html" }, | |
}); | |
}, | |
}); | |
console.log(`Server running @ ${server.hostname}:${server.port}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment