@ogygia/devtools · API
@ogygia/devtools/vite
The devtools() Vite plugin and its options, the dock's and the profiler's.
On this page
- devtools
- DevtoolsOptions
- DevtoolsOptions.dock
- DevtoolsOptions.profiler
- ProfilerOptions
- ProfilerOptions.secret
- ProfilerOptions.path
- ProfilerOptions.sampleInterval
- ProfilerOptions.maxReports
- ProfilerOptions.recentRequests
- ProfilerOptions.network
- ProfilerOptions.serverTiming
- ProfilerOptions.heap
- ProfilerOptions.enabled
- ProfilerOptions.onDemand
- ProfilerOptions.trap
- ProfilerOptions.clientCpu
- ProfilerOptions.sink
- ProfilerOptions.sample
- ProfilerOptions.store
This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.
Exports devtools · DevtoolsOptions · ProfilerOptions
import { … } from '@ogygia/devtools/vite';function devtools(options?: DevtoolsOptions): [OgygiaPlugin<DevtoolsServerOptions>, ...Plugin[]];DevtoolsOptions
interface
DevtoolsOptions.dock
The dock and core's events (default true).
DevtoolsOptions.profiler
The SSR profiler: true or its options (default off).
interface DevtoolsOptions {/*…*/}dock?: boolean;profiler?: boolean | ProfilerOptions;ProfilerOptions
interface
ProfilerOptions.secret
Auth secret. Defaults to the OGYGIA_PROFILER_SECRET env var. Required outside dev — with no secret in production the profiler UI is disabled (the always-on request log still collects, invisibly).
ProfilerOptions.path
Base path for the UI. Default '/__profiler'.
ProfilerOptions.sampleInterval
Sampling interval in microseconds for recordings. Default 500.
ProfilerOptions.maxReports
How many finished profiles to keep in memory (each gzipped). Default 6.
ProfilerOptions.recentRequests
How many requests the rolling log keeps. Default 500.
ProfilerOptions.network
Patch fetch/http to attribute outbound calls. Default true. In production the per-request AsyncLocalStorage that does the attributing exists only while a profile is being recorded (idle requests pay nothing); in dev it is always on. Set false to skip the global fetch/http patch entirely: wall timing only, never any network view.
ProfilerOptions.serverTiming
Add Server-Timing headers to every response. These expose internal render and network timings to every client, so the default is ON in dev and OFF in production — set true to force it on.
ProfilerOptions.heap
Take a heap allocation profile during recordings. Default true.
ProfilerOptions.enabled
Master switch. Default true.
ProfilerOptions.onDemand
DEMAND-ONLY. The profiler module (node:inspector, crypto, its UI-rendering path) is not imported, parsed or initialised until a request actually hits the profiler path — so until you open the dashboard the app pays EXACTLY what an app with no profiler pays: no cold-start import, no always-on request log, no per-request wrap. The trade is no history: the profiler starts collecting from the first visit onward, not before. Recommended on serverless (Amplify / Lambda), where every cold start would otherwise pay the profiler's import on its TTFB. Default false (the profiler mounts on the first request and its always-on log collects from boot). Off by default so nothing changes for existing setups.
ProfilerOptions.trap
CATCH THE SLOW ONE. Keep a coarse sampler running in rolling windows and keep a report only
when a request in the window took longer than over ms — the p99 request you cannot
reproduce. Built to stay cheap: a 10 ms sampling interval, no per-request context, no stack
capture, no heap sampling; the request is matched to the window by time. Off by default; off
on serverless hosts (an instance dies before it catches anything). Stops after keep reports.
ProfilerOptions.clientCpu
A CPU PROFILE IN THE BROWSER for the profiler's own user: their documents get the Document-Policy: js-profiling header, the runtime samples the main thread while the page
hydrates (Chromium's JS Self-Profiling API) and posts the trace through the beacon; the report
shows it as components, functions and a flame graph for hydration. Default true; a visitor is
never sampled (no tag, no policy, no profiler).
ProfilerOptions.sink
THE SINK — for a host whose instances live seconds (Amplify, Lambda). Each instance posts what
it saw as NDJSON to this URL before it dies: one small row per request, one summary per
always-on sampler window, a caught request's dump. key goes as a bearer token (default: the
profiler secret). A long-lived host posts every every ms (default 10 s); a serverless one
posts after each request. The site view (<base>/site) reads the rows back from any URL you
serve them from: the request cloud and the layer cake of the whole site, over days.
ProfilerOptions.sample
ALWAYS-ON SAMPLING. Every every seconds take one window ms coarse sample (10 ms interval)
and fold it into a rolling "hot functions over the last hour" table on the dashboard. The
accuracy comes from volume, not from one capture. Default off; off on serverless.
ProfilerOptions.store
WHERE REPORTS LIVE. Default: this instance's memory (lost on restart; each browser keeps its
own copies). Not a devtools({ profiler }) option: a store is a live object the build-time
options cannot carry, so the app sets it at runtime with setProfilerStore(store) from @ogygia/devtools/profiler/storage, in hooks.server.ts, and the server half passes it in here
when the profiler mounts. A store is new SqliteStore(…), new RedisStore(…) or new PostgresStore(…) from @ogygia/devtools/profiler/storage/{sqlite,redis,postgres}, or your own; every finished
report is written there and read back from there, so it survives the instance that made it and
a whole team shares one list. The store is dual-written: memory stays the hot cache, the store
the source of truth.
interface ProfilerOptions {/*…*/}secret?: string;path?: string;sampleInterval?: number;maxReports?: number;recentRequests?: number;network?: boolean;serverTiming?: boolean;heap?: boolean;enabled?: boolean;onDemand?: boolean;trap?: {
over: number;
interval?: number;
window?: number;
keep?: number;
replay?: string[];
};clientCpu?: boolean;sink?: {
url: string;
key?: string;
every?: number;
};sample?: {
every?: number;
window?: number;
interval?: number;
};store?: ProfilerStore;