Interface Server

HTTP & HTTPS Server

To start the server, see serve

Often, you don't need to interact with this object directly. It exists to help you with the following tasks:

  • Stop the server
  • How many requests are currently being handled?

For performance, Bun pre-allocates most of the data for 2048 concurrent requests. That means starting a new server allocates about 500 KB of memory. Try to avoid starting and stopping the server often (unless it's a new instance of bun).

Powered by a fork of uWebSockets. Thank you @alexhultman.

Hierarchy

  • Server

Properties

development: boolean
hostname: string
pendingRequests: number

How many requests are in-flight right now?

port: number

Methods

  • Stop listening to prevent new connections from being accepted.

    It does not close existing connections.

    It may take a second or two to actually stop.

    Returns void

  • Stop listening to prevent new connections from being accepted.

    It does not close existing connections.

    It may take a second or two to actually stop.

    Returns void

Generated using TypeDoc