Created
November 16, 2022 12:10
-
-
Save ikku47/828e1071d4d53331a2dc60b9cc7a1639 to your computer and use it in GitHub Desktop.
simple bun code for a react page.
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 {renderToReadableStream} from 'react-dom/server'; | |
const dt = new Intl.DateTimeFormat(); | |
export default { | |
port: 3000, | |
async fetch(request) { | |
return new Response( | |
await renderToReadableStream( | |
<html> | |
<head> | |
<title>Hello World</title> | |
</head> | |
<body> | |
<h1>Hello from React!</h1> | |
<p>The date is {dt.format(new Date())}</p> | |
</body> | |
</html> | |
) | |
); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment