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. |
The package also exports the types NextToolbarProps and Theme.
next.config options
| Option | Recommended | Why |
|---|---|---|
experimental.requestInsights | true (Next 16) | 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 in Next 16. Next 15 ignores it, so the same config works on both.
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 |
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.
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'
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.3.6' and 'system' |
Production
There is nothing to switch off. The toolbar renders null whenever NODE_ENV isn't development.