Open source · npm developer tooling · Created & maintained by Kavinkumar M

next-server-api-debugger
Server API logs, closer to your browser.

When Next.js makes API requests on the server, those outgoing calls do not appear as requests in your browser's Network tab. I created this npm package to help surface supported server-side fetch events in the browser Console while developing locally.

Graphic showing GET and POST API requests with HTTP status and duration in a browser console
An illustration of the debugging workflow. The API values are examples, not measured results.

What problem does this solve?

In an App Router application, some API calls happen in server code rather than in your visitor's browser. That makes the browser Network tab incomplete for investigating server-to-server fetch calls. Terminal logs and tracing are useful, but a local Console view can make development feedback easier to follow.

next-server-api-debugger aims to capture supported outgoing fetch() calls, including method, URL, HTTP response status, duration, and sanitized request/response previews. It forwards events to an authenticated local browser session, so you can inspect expandable Console groups.

Quick start

In the root of a compatible Next.js 16 App Router project, install the package and run its initializer:

npm install next-server-api-debugger
npx next-server-api-debugger init

The setup command prompts for a developer key and generates or connects required instrumentation and local routes. It tries to preserve existing application code rather than replacing unrelated handlers. Review generated files in Git before committing.

Restart your Next.js development server:

npm run dev

In your local app's browser DevTools Console, enable the session with your chosen key:

localStorage.setItem("apiDebugLogging", "YOUR_KEY")

The browser script verifies the key against the local server. Once authenticated, a supported server-side fetch request can appear in the browser Console. A valid key is required; the tool does not expose your original key in plaintext.

What it supports

  • Automatic integration for supported Next.js 16 App Router / Node.js development apps, including JavaScript and TypeScript layouts.
  • Best-effort logging of server-side fetch() requests, with methods such as GET, POST, PUT, PATCH, and DELETE.
  • Request and response previews, HTTP status, and elapsed time, when available.
  • A local browser Console view and a development terminal fallback.
  • Key setup and rotation with npx next-server-api-debugger init --reset.

For requests that are not automatically intercepted, the package offers an optional explicit debugFetch() wrapper.

Important limitations

This is a local development tool, not a production observability service. The automatic interceptor cannot guarantee capture of every Next.js request. Axios, raw Node.js HTTP libraries, database queries, Edge runtime requests, and multi-instance production logging are not automatically supported.

Logging can expose private data. The package uses best-effort field sanitization, but developers should work with synthetic or otherwise safe test data. Browser localStorage is not a secure vault. Do not reuse an application password as the debug key or expose local debug endpoints publicly.

Developer handover and maintainability

For team projects, run npx next-server-api-debugger status to check whether local integration and a key are configured. The tool stores a salted key hash, so a departing developer's original key cannot be recovered from configuration. A new maintainer can rotate the key with init --reset. Uninstalling and reinstalling the npm package does not automatically reset the application's .env.local.

About the creator

I'm Kavinkumar M, an Angular and Next.js developer. I created and maintain next-server-api-debugger as a personal open-source developer-tool project. You can read the engineering explanation, check the source and issues, or explore my other work.

Further reading

Why your browser Network tab cannot show every server API call

Read the practical guide