Skip to main content
This snippet reads a file from disk using Bun.file(). This returns a BunFile instance, which can be passed directly into the new Response constructor.
server.ts

The Content-Type is read from the file and automatically set on the Response.
server.ts

Putting it all together with Bun.serve().
server.ts

See Docs > API > File I/O for complete documentation of Bun.write().