Configuration
The theme prop, the recommended next.config options, basePath and assetPrefix.
NextToolbar needs no configuration to work. This page lists what you can configure, in the component and in next.config.
Props
<NextToolbar theme="system" />| Prop | Type | Default | Description |
|---|---|---|---|
theme | 'system' | 'light' | 'dark' | 'system' | Initial theme. system follows the OS preference. The theme button in the toolbar overrides it and remembers the choice per browser. |
securityCheck | boolean | true | Check your Next.js version against GitHub's security advisories. See Security. |
The package also exports the types NextToolbarProps and Theme.
next.config options
| Option | Recommended | Why |
|---|---|---|
experimental.requestInsights | true (Next 16.3+) | Unlocks server timing, fetches with cache outcome, server errors, exact route patterns, the no-store render-mode correction and the profiler. |
devIndicators | { position: 'top-right' } or false | Next's indicator sits bottom-left by default, on top of the toolbar's logo. |
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
devIndicators: { position: 'top-right' },
experimental: { requestInsights: true },
}
export default nextConfigrequestInsights only exists from Next 16.3. On older versions TypeScript flags it as an unknown option in next.config.ts, so only add it on 16.3+.
basePath and assetPrefix
Both work without extra configuration:
- The toolbar finds the dev server's socket the same way Next's own client does: from the path of Next's scripts (everything before
/_next/). That coversbasePath, andassetPrefixincluding a CDN URL. - Next writes
basePathinto the toolbar's code at build time (process.env.__NEXT_ROUTER_BASEPATH), so it can match URLs that include it (/docs/blog/hello) with the paths Next reports without it (/blog/hello).
Persisted preferences
The toolbar stores two small preferences in the browser's localStorage, per origin:
| Key | Values | Set by |
|---|---|---|
next-toolbar:collapsed | '1' or '0' | Minimizing / expanding the toolbar |
next-toolbar:theme | 'system', 'light', 'dark' | The theme button |
next-toolbar:seen | JSON list of segment names | Opening a segment that has the new badge |
Clear them to go back to the defaults. If localStorage is unavailable (private mode, blocked storage), the toolbar still works and simply doesn't remember.
Other devtools on the page
While the bar is expanded, the toolbar sets --next-kit-inset-bottom on <html> to the room it takes at the bottom edge (its height plus its margin, 53px by default). Minimized to a circle, or unmounted, it removes it.
It's a contract shared by the @angelitolm devtools: next-query's button and panel add it to their bottom offset, so they float above the bar instead of covering it. Any floating widget of your own can do the same:
.my-widget { bottom: calc(16px + var(--next-kit-inset-bottom, 0px)); }Server route
Optional. @angelitolm/next-toolbar/server exports two route handlers; mount them at /api/next-toolbar:
export { GET, POST } from '@angelitolm/next-toolbar/server'| Method | Does |
|---|---|
GET | Returns the Server Action names, read from Next's server-reference-manifest.json files in .next. |
POST | Runs revalidatePath or revalidateTag with what the toolbar sends. |
- Both answer 404 outside
next dev, so deploying the file is harmless (unless you opt in on a staging server). - They also answer 404 unless the request carries the
x-next-toolbarheader. Browsers only send a custom header to another origin after a CORS preflight, which this route never approves, so another site open in your browser can't call it. - The path is fixed. If a
middleware/proxyguards/api, let/api/next-toolbarthrough in development. - It reads the manifests from
.nextin the directorynext devruns in: with a customdistDir, action names won't be found (revalidating still works).
Error boundary
Not a toolbar option, but worth repeating: add app/error.tsx so a render error doesn't take the root layout, and the toolbar, down with it. See Getting started.
Demo component
NextToolbarDemo renders the same toolbar from data you pass in, in any environment, production included. It's what powers the live demo; use it for documentation, screenshots or showcases, not in your app.
'use client'
import { NextToolbarDemo } from '@angelitolm/next-toolbar/demo'
export default function Showcase() {
return <NextToolbarDemo pathname="/blog/hello" params={{ slug: 'hello' }} status={200} timingMs={42} isStatic />
}| Prop | Description |
|---|---|
pathname, params | The simulated page |
status, timingMs, via | HTTP status and TTFB ('document') or navigation time ('rsc') |
isStatic | What Next's dev data says: true, false, or omitted for "Rendering…" |
insights | Simulated request insights (types Insight, InsightFetch, InsightSpan are exported) |
clientErrors | Client errors with message and optional stack |
nextVersion, theme | Defaults: '16.4.1' and 'system' |
Production
There is nothing to switch off. In a production build the toolbar renders null, makes no request and opens no connection. Its code sits in a separate chunk that pages never load for your visitors.
Staging (self-hosted QA)
NextToolbar is a development tool. It does not belong in a production environment, and nothing in the package turns it on there by itself.
A staging server used for specific QA testing is the one exception, and it is a decision your development team makes on purpose: the toolbar stays off until someone sets the secret below on that server. Do it only on staging, only for the time QA needs it, and never on the environment your users reach.
Never in production
Do not set NEXT_TOOLBAR_SECRET in production, not even temporarily to debug. With the server route mounted, whoever holds the secret can list your Server Actions and revalidate your cache.
To enable it on a self-hosted staging server (next build + next start):
-
Mount the server route: it is what decides who gets in.
-
Set a secret of at least 16 characters on the server:
bashNEXT_TOOLBAR_SECRET=a-long-random-string -
In the browser that should see the toolbar, set the same value as the
next-toolbarcookie (once, from the DevTools console):jsdocument.cookie = 'next-toolbar=a-long-random-string; path=/; max-age=2592000; samesite=strict' -
Reload the page. The toolbar appears for that browser only.
What QA sees on staging
A production build has no Next dev server, so everything that comes from it is missing. The rest works as in development.
| Works | Missing, and why |
|---|---|
| HTTP status, TTFB and client navigation time | Render mode (Static / Dynamic): Next only sends it over the dev server's HMR socket |
| Cached fetches: every fetch in Next's data cache, newest first, with HTTP status, freshness, tags, response headers and revalidate buttons (details) | Fetches per request, their time and HIT / MISS / SKIP: they come from experimental.requestInsights, which only next dev emits |
| Server Actions with their names (read from the build's manifests), status, time, revalidation and redirects | Server render time and the span profiler: also request insights. The profiler falls back to the page visits the browser recorded |
| Revalidate by tag or path | Exact route pattern: rebuilt from the URL and useParams() instead |
| SEO, broken links, client errors, security check | The HMR socket row in the info panel reads none (production build) |
How the access check works
- Without the variable, or with one shorter than 16 characters, production behaves exactly as described in Production.
- On every page load,
<NextToolbar>looks for anext-toolbarcookie. Without it, it does nothing: no request, no toolbar code downloaded. Your visitors never pay for the toolbar. - With the cookie, it calls the server route once. The server compares the cookie with the secret in constant time and answers 200 or 404. Only on 200 does the browser download the toolbar's chunk.
- The server route checks the secret on every
GETandPOST, so the revalidate buttons can't be used without it either. A wrong cookie gets the same 404 as none.
Turn it off
- For one browser: delete the cookie,
document.cookie = 'next-toolbar=; path=/; max-age=0', and reload. - For everyone: remove
NEXT_TOOLBAR_SECRETfrom the server and restart it. Rotate the value whenever someone who knew it leaves the team. - Treat the secret like a password: never put it in a
NEXT_PUBLIC_variable (that ships it to every browser), a URL or the repository.
Limits
- Self-hosted only. The cached-fetch list reads
.next/cache/fetch-cachefrom the server's disk, so it needs onenext startprocess with Next's default cache. On Vercel, other serverless platforms or with a customcacheHandler(Redis…), the list is empty or partial; the rest of the toolbar still works. - The route reads the manifests and the cache from
.nextin the directorynext startruns in. With a customdistDir, action names and cached fetches won't be found. - If a
middleware/proxyguards/api, let/api/next-toolbarthrough on staging too.
Not showing up? See Troubleshooting.