ELPOD / DOCS FOUNDATIONS

foundations / reference

Elysia Plugins and Elpod Bootstrap

Compose native Elysia plugins with Elpod application providers and explicit bootstrap configuration on Bun.

Elpod composes Elysia plugins with explicit application providers and bootstrap configuration on Bun. Use plugins for native Elysia capabilities while keeping plugin order and dependency ownership visible.

The idea

An extension should be easy to answer two questions about: “What does it install?” and “When does it run?” Elpod keeps both answers visible. A reusable plugin is a named crew member; a bootstrap callback is a one-time adjustment made at launch.

How Elpod provides it

Elpod has two explicit extension points. A Elpod plugin is named and can own providers plus a native Elysia configure function. The bootstrap({ configure }) callback is an unnamed, one-off application hook.

import { application, plugin } from "@elpod/core";

const requestLogging = plugin({
  name: "request-logging",
  providers: [RequestLogger],
  configure: (elysia) => elysia.onRequest(({ request }) => {
    console.log(request.method, request.url);
  }),
});

export const app = application({
  features: [hello],
  plugins: [requestLogging],
});

Plugins are applied in declaration order and must return the Elysia instance. Plugin providers participate in the normal application DI graph, lifecycle, and test overrides.

const server = await bootstrap(app, {
  configure: (elysia) => healthRoutes(elysia),
});

Use configure for local application wiring such as health routes, OpenAPI routes, or a one-off native hook. Use a named plugin when a reusable extension needs a name, providers, or ordering in the composition root.

Common mistakes

  • Treating a plugin as a separate router. It receives native Elysia.
  • Forgetting to return the configured instance.
  • Adding provider dependencies in a closure instead of registering them explicitly.
  • Applying a security-sensitive plugin after routes when its hook needs to run before them; verify the Elysia lifecycle order.

Production notes

Elpod does not validate the security or correctness of a plugin’s native Elysia code. Keep plugin order reviewable, test the composed app, and avoid plugins that log credentials or request bodies.

Routing and controllers · Provider boundaries · Configuration.