blob: 62d1151d517e525f94a8f42c4ecf77c161dc0378 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// A simple way to connect FileSystemRouter to Bun#serve
// run with `bun run index.tsx`
import { renderToReadableStream } from "react-dom/server";
import { FileSystemRouter } from "bun";
export default {
port: 3000,
async fetch(request: Request) {
const router = new FileSystemRouter({
dir: process.cwd() + "/pages",
style: "nextjs",
});
const route = router.match(request);
const { default: Root } = await import(route.filePath);
return new Response(await renderToReadableStream(<Root {...route.params} />));
},
};
|