serve

Reference

serve(options: ServeOptions): { port: number; hostname: string; server: ReturnType<typeof Deno.serve>; }

The serve function is used to start the Deno server and listen for incoming requests.

Example usage:

In the next example, we use the serve function to start the Deno server.

import { serve } from "brisa/server/deno";

const { server, port, hostname } = serve({
  port: 3001,
});

console.log(
  "Deno Server ready ๐Ÿฅณ",
  `listening on http://${hostname}:${port}...`,
);

Keep in mind that the serve for Deno is not in brisa/server but in brisa/server/deno.

It only makes sense to use it if you need a custom server for extra things from the serve but if you start the server in the same way as Brisa.

Types

export function serve(options: ServeOptions): {
  port: number;
  hostname: string;
  server: ReturnType<typeof Deno.serve>;
};