Stream Plugin

This plugin add support for streaming response or sending Server Sent Event back to client.

Install with:

bun add @elysiajs/server-timing

Then use it:

import { Elysia } from "elysia";
import { serverTiming } from "@elysiajs/server-timing";

new Elysia()
  .get("/", () => "hello")

Server Timing then will append header 'Server-Timing' with log duration, function name and detail for each life-cycle function.

To inspect, open browser developer tools > Network > [Request made through Elysia server] > Timing.

Then inspect the Server Timing of your server


Below is a config which is accepted by the plugin


@default NODE_ENV !== 'production'

Determine whether or not Server Timing should be enabled


@default undefined

A condition whether server timing should be log


@default undefined

Allow Server Timing to log specified life-cycle events:

Trace accepts object of the following:

  • request: capture duration from request
  • parse: capture duration from parse
  • transform: capture duration from transform
  • beforeHandle: capture duration from beforeHandle
  • handle: capture duration from handle
  • afterHandle: capture duration from afterHandle
  • total: capture total duration from start to finish


Below you can find the common patterns to use the plugin.

Allow Condition

You may disabled Server Timing on specific route via allow property

import { Elysia } from "elysia";
import { serverTiming } from "@elysiajs/server-timing";

new Elysia().use(
    allow: ({ request }) => {
      return new URL(request.url).pathname !== "/no-trace";