1. Start a server
Bun.serve spins up a fast built-in HTTP server with no external dependencies.
Bun.serve({Typorithm · easy
Step 1 of 8 · intro card
Bun APIs
Bun.serve starts a fast built-in HTTP server. Its fetch handler receives a Web-standard Request and must return a Web-standard Response — the same fetch API you use in the browser.
Bun.serve creates an HTTP server entirely in native code, so there is no need for a framework like Express to handle the basics.
The fetch handler is the heart of the server: it is called once per request with a Web-standard Request object and returns a Response.
Because it speaks the Web fetch standard, the same handler shape works across Bun, browsers, and edge runtimes — you return new Response(body, init).
Bun.serve starts a built-in HTTP server.
fetch(req) handles each request.
Return a Web-standard Response.
const server = Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello");
},
});Connect each part of the code to the concept before you type.
Bun.serve spins up a fast built-in HTTP server with no external dependencies.
Bun.serve({The port option chooses which TCP port the server binds to.
port: 3000,The fetch handler receives a Web-standard Request and runs once per incoming request.
fetch(req) {You return a Web-standard Response object, exactly like in browsers and other runtimes.
return new Response("Hello");Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.