Adapters
Framework adapters are thin wrappers around createFetchHandler. The handler is web-standard ((Request) => Promise<Response>), so adapters for any fetch-based framework are one page of code.
Elysia — @xtandard/flags/elysia
Section titled “Elysia — @xtandard/flags/elysia”Elysia.mount accepts a web-standard fetch function, so the adapter is a direct pass-through.
import { Elysia } from "elysia";import { flagsPanel } from "@xtandard/flags/elysia";import { createRedisStorage } from "@xtandard/flags/storage/redis";import { basicAuth } from "@xtandard/flags/auth/basic";import { rolesAuthorization } from "@xtandard/flags/authorization/roles";
const panel = flagsPanel({ basePath: "/flags", sourceStorage: createRedisStorage({ url: process.env.REDIS_URL!, prefix: "app:flags:source" }), runtimeStorage: createRedisStorage({ url: process.env.REDIS_URL!, prefix: "app:flags:runtime" }), auth: basicAuth({ users: [{ username: "admin", passwordHash: process.env.HASH!, roles: ["admin"] }], }), authorization: rolesAuthorization(),});
new Elysia().mount("/flags", panel).listen(3000);
// Access the admin core from outside the panel (e.g. to seed test data):const core = panel.core;flagsPanel from @xtandard/flags/elysia returns a function with a .core property attached, giving you access to the FlagsCore instance for programmatic use.
CORS +
.mount(): a mounted handler is opaque to the host’s lifecycle hooks, so a host-levelcors()plugin generally does not wrap the panel routes — and the panel does not inherit that config. For a cross-origin embed, pass CORS to the panel itself:flagsPanel({ …, cors: { origin, credentials: true } })(see UI.md → Cross-origin embed). Set it on exactly one layer — if both the host plugin and the panel emitAccess-Control-Allow-Origin, browsers reject the duplicate. If you instead useflagsElysia(the typed plugin below), it declares real routes that the hostcors()does wrap, so leave the panelcorsunset in that mode.
Hono — @xtandard/flags/hono
Section titled “Hono — @xtandard/flags/hono”Returns a Hono sub-app that catches all routes and delegates to the panel handler.
import { Hono } from "hono";import { flagsPanel } from "@xtandard/flags/hono";import { createRedisStorage } from "@xtandard/flags/storage/redis";
const panel = flagsPanel({ basePath: "/flags", sourceStorage: createRedisStorage({ url: process.env.REDIS_URL!, prefix: "app:flags:source" }),});
const app = new Hono();app.route("/flags", panel);
export default app;
// Access core:const core = panel.core;Bun — @xtandard/flags/bun
Section titled “Bun — @xtandard/flags/bun”The panel handler is already a web-standard fetch function, so the Bun adapter is a pure passthrough that returns the CreateFetchHandlerResult directly.
import { flagsPanel } from "@xtandard/flags/bun";import { createRedisStorage } from "@xtandard/flags/storage/redis";
const panel = flagsPanel({ sourceStorage: createRedisStorage({ url: process.env.REDIS_URL!, prefix: "app:flags:source" }),});
Bun.serve({ port: 3000, fetch: panel.fetch,});
// Access core:const core = panel.core;For a root-mounted panel, omit basePath. For a sub-path, set it and strip the prefix in your outer fetch:
Bun.serve({ port: 3000, async fetch(request) { const url = new URL(request.url); if (url.pathname.startsWith("/flags")) { return panel.fetch(request); } return new Response("Not found", { status: 404 }); },});FlagsPanelOptions Reference
Section titled “FlagsPanelOptions Reference”| Option | Type | Default | Description |
|---|---|---|---|
sourceStorage |
FlagsStorage |
required | Canonical store for drafts, history, audit. |
runtimeStorage |
FlagsStorage |
sourceStorage |
Published-snapshot store read by the runtime. |
basePath |
string |
"" |
Mount prefix, e.g. "/flags". |
auth |
AuthProvider |
anonymous | Authentication provider. |
authorization |
AuthorizationProvider |
allow all | Authorization provider. |
readonly |
boolean |
false |
Block all mutating operations. |
title |
string |
"@xtandard/flags" |
Navbar wordmark shown in the UI. |
logoUrl |
string |
— | Logo image URL (replaces the title wordmark). |
defaultProjectKey |
string |
"default" |
Default project for the core. |
defaultEnvironmentKey |
string |
"production" |
Default environment for the core. |
uiDir |
string |
dist/ui beside the module | Directory to serve the bundled UI from. |
core |
FlagsCore |
— | Reuse an existing core instead of constructing one. |
Express (@xtandard/flags/express)
Section titled “Express (@xtandard/flags/express)”Express predates the Fetch API, so the adapter bridges Node req/res to the
web-standard handler. Mount it before any body-parsing middleware — it reads
the raw request body itself.
import express from "express";import { flagsPanel } from "@xtandard/flags/express";import { createRedisStorage } from "@xtandard/flags/storage/redis";
const app = express();
app.use( "/flags", flagsPanel({ basePath: "/flags", sourceStorage: createRedisStorage({ url: process.env.REDIS_URL! }), }),);
// Your own JSON routes can mount their parsers after the panel.app.use(express.json());app.listen(3000);The returned handler also carries .core for programmatic access to the admin
operations (publish, rollback, etc.).