Skip to content

Add http.serve() API based on Fetch (Request -> Response) #63096

@efekrskl

Description

@efekrskl

What is the problem this feature will solve?

Node provides fetch, Request/Response, and Web Streams, but no high level server API using this model.

Other runtimes such as Deno and Bun expose a serve API based on the Fetch contract. In Node, similar patterns are commonly implemented in userland (e.g., frameworks like Hono), which indicates demand for this abstraction.

This was discussed in #42529 and received support, however that issue is focused on request.toWeb(), so opening a separate issue focused on this API.

What is the feature you are proposing to solve the problem?

Add a high-level http.serve(handler) API.

An example shape could be:

http.serve((req) => new Response("ok"))

handler: (Request) => Response | Promise<Response>

This would coexist with the existing http.createServer, and be a high level alternative using WHATWG APIs instead.

What alternatives have you considered?

  • Continue using http.createServer directly.
  • Implement this in userland, or use existing 3rd party solutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions