Server
createManicServer
Bun.serve bootstrap for Manic apps — HTML bundle or string config routes plugins API modes.
createManicServer(options)
Primary export from manicjs/server. Loads ManicConfig (unless overridden), discovers routes when omitted, mounts static/API/plugin handlers, and returns the Bun.serve handle.
import { createManicServer } from 'manicjs/server';
import app from './app/index.html';
export default await createManicServer({
html: app,
});Signature
function createManicServer(options: {
html: string | (() => string | Promise<string>) | HTMLBundle;
config?: ManicConfig;
routes?: RouteInfo[];
envKeys?: string[];
startTime?: number;
}): Promise<ReturnType<typeof Bun.serve>>;Options
| Field | Purpose |
|---|---|
html | Dev HTMLBundle from import './app/index.html' or raw HTML string / async loader in advanced setups |
config | Skip loadConfig() — supply frozen config object |
routes | Override filesystem discovery — rarely needed |
envKeys | Public env names surfaced to window.__MANIC_ENV__ injection paths |
startTime | performance.now() anchor for CLI banner timings |
Modes
config.mode | Behavior highlights |
|---|---|
frontend | SPA only · optional dev /sitemap.xml · no Hono API graph |
fullstack | Loads apiLoaderPlugin, exposes /api, /openapi.json, /.well-known/api-catalog |
Deep dive: Server runtime.
Plugins & HTML injection
Plugins run configureServer with addRoute, addLinkHeader, and injectHtml — mirrored concepts to createPlugin (Plugins).