@ogygia/devtools
Devtools
@ogygia/devtools adds two tools to your app with one Vite plugin. The dock sits on the page and shows each region, its real JS cost, what crossed the wire and when it woke, and the SSR profiler at /__profiler shows why a server render is slow.
Your browser’s devtools show elements, scripts and network requests. They don’t know which parts of an ogygia page are islands, which are plain server HTML, what each island cost to download, or why one of them woke late. And they can’t see the server at all, so a slow render looks like a long wait for the first byte.
@ogygia/devtools fills both gaps. It’s one package with two tools:
- The dock is a panel on the page itself. It outlines every region in place, lists what each one costs in JavaScript, shows the data that crossed from the server, and times when each island woke. It reads the same events the runtime sends as it works, so what it shows is what happened, not an estimate.
- The SSR profiler lives at
/__profiler. It renders a page through your real server and names the components, functions, outbound calls and allocations that made it slow, without any timing code of your own.
You turn both on with one plugin in vite.config.ts. Where you don’t list the plugin, none of it is in your app.
import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { devtools } from '@ogygia/devtools/vite';
import { defineConfig } from 'vite';
export default defineConfig(({ mode }) => ({
plugins: [
ogygia(),
...(mode !== 'production'
? [devtools({ profiler: true })]
: []) ,
sveltekit()
]
}));Installation
Install @ogygia/devtools, then list devtools() after ogygia() and before sveltekit(), as in the example above. There’s nothing to add to hooks.server.ts: ogygia.handle() runs the plugin’s server half, which serves the profiler, and writes the server’s events into each page for the dock.
Because the plugin list is ordinary code, you decide where the devtools are on. The recommended default is everywhere except production builds: the dev server, plus any preview or QA build that runs in another mode (vite build --mode staging). A build that does list the plugin shows nothing to visitors until a browser turns the devtools on. Builds covers that. Keeping the profiler in a production build is an advanced option with known caveats; Production explains it.
pnpm add @ogygia/devtoolsOptions
devtools() takes two options:
| Option | Default | What it does |
|---|---|---|
dock | true | The dock, and the runtime events it reads. On the dev server its launcher shows on every page. In a build it stays hidden until a browser turns it on with ?og-devtools=on. |
profiler | off | The SSR profiler. Pass true, or an object of its options ({ secret, path, sampleInterval, … }, listed under Configuration). In a build, its pages stay closed until you set a secret (OGYGIA_PROFILER_SECRET). |
So devtools() is the dock alone, devtools({ profiler: true }) is both, and devtools({ dock: false, profiler: true }) is the profiler without the dock. With the dock off, pages still carry the small script that sends the profiler what the browser measured, so the profiler’s reports keep their browser side.
import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { devtools } from '@ogygia/devtools/vite';
import { defineConfig } from 'vite';
export default defineConfig(({ mode }) => ({
plugins: [
ogygia(),
...(mode !== 'production'
? [
devtools({
dock: false,
profiler: true
})
]
: []),
sveltekit()
]
}));Dev and builds
The devtools are compiled in only where the plugin is listed. Where it isn’t, the runtime’s event calls, the dock, its styles and the profiler all fold out of the build, and the app pays nothing.
Where it is listed, what a page carries depends on where it runs:
| Where | The dock | The profiler |
|---|---|---|
vite dev | Always on. The launcher shows on every page, and the dock’s code loads once the page is idle. | Open at /__profiler, with no login, to anyone who can reach the dev server. Don’t expose vite dev --host on a network you don’t trust. |
| A build, for a visitor | Nothing to see. No launcher, no measuring, no server events in the HTML. The runtime still keeps its events in memory. | No secret: /__profiler answers a plain 404. A secret under 16 bytes: the path is passed on to your app. 16 bytes or more: the login. |
| A build, in a browser that turned it on | The launcher shows. The dock’s code loads when you open it. Pages are measured from the start. | The same login. The dock’s Profiler and Record tabs reach it once you’ve logged in. |
A build with the dock listed prints devtools_on_in_build once, so a dock left on by mistake gets noticed before it ships. Its advice, listing the plugin only when mode !== 'production', is the recommended default; if you keep the profiler in on purpose, keep only the dock out with dock: mode !== 'production' (#2304, item 22). Profiler: login explains the profiler’s login.
First look
Start the dev server and open any page with csr = false. Click og devtools at the bottom right to open the dock, or press Alt+O (not yet on a Mac, #2304). In the Lens tab, press show overlay to see every region outlined on the page, with a list of each one’s kind, wake, JS cost and state beside it.
Then open /__profiler in another tab, and profile the same page by its path to see where its server render spent its time. With profiler: true, the dock’s Profiler tab runs the same profile without leaving the page.
Integrations
@ogygia/testing turns what the dock and the profiler measure into checks in your Playwright tests. The app under test lists this plugin, and the tests use the fixture it defines in tests/fixtures.ts:
hydration() reads what the dock’s Hydration tab shows, and profile() reads the profiler’s report.
@ogygia/cli runs the profiler in CI. npx ogygia perf --url <origin> --pages /,/docs renders each page under the profiler and fails when a page misses its budget, and ogygia bisect finds the commit that made a page slower (Perf budgets).
import { test, expect } from './fixtures';
test('home stays light', async ({ page, ogygia }) => {
await page.goto('/');
expect(await ogygia.hydration()).toHydrateCleanly();
expect(await ogygia.profile('/')).toMeetBudget({ score: 80 });
});Next steps
The dock:
- Dock: turn it on in dev and in a build, open it, and what each tab is for.
- Region inspector: the Lens overlay, one island’s card, and the Hydration, Bytes, Wire, Hub, Nav and Timeline tabs.
- Page load: the Page tab, and the Profiler tab beside it.
- Page findings: every problem the Page tab can name, and its fix.
- Session recording: measure what using the page does, browser and server together.
- Event stream: the events behind the dock, for your own tools.
The profiler:
- SSR profiler: turn it on, dev against builds, the dashboard.
- Recording: profile a page, one request, a window, or the slow request with the trap.
- Configuration: every option,
Server-Timing, environment variables and overhead. - Production: the secret, the login, serverless hosts, source maps and error codes.
- Report storage: stores, exports, share links and the site sink.
- Scripts and CI: the JSON report, every route, MCP,
ogygia perfandogygia bisect. - Custom spans:
span(),instrument(),tag()and the browser’smark(). - Reports: the first fixes, the page score, and a map of every part.
- Slow patterns, Render timeline, CPU, Memory, Page data and Browser metrics: each part of a report.
- Comparisons: did the fix work, and the whole site.
- Findings: every finding code and its threshold.
API: @ogygia/devtools, /report, /profiler, /profiler/client, /profiler/storage with its /sqlite, /redis and /postgres adapters, and /vite.