Next.js supports full source maps for both frontend and backend code. This guide covers debugging with VS Code, browser DevTools, and JetBrains WebStorm.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vercel/next.js/llms.txt
Use this file to discover all available pages before exploring further.
VS Code
Create a.vscode/launch.json file at the project root:
- For Firefox debugging, install the Firefox Debugger extension.
- For the full-stack config, change
debugWithEdgetodebugWithChromeif you use Chrome. - If using a Turborepo, add
"cwd": "${workspaceFolder}/apps/web"to server-side and full-stack configurations. - Replace
3000with your custom port if needed.
Ctrl+Shift+D / ⇧+⌘+D), select a configuration, and press F5 to start debugging.
JetBrains WebStorm
- Click the run configuration dropdown and select Edit Configurations
- Create a JavaScript Debug configuration with
http://localhost:3000as the URL - Run the configuration—the browser opens automatically and both the Node.js and browser processes are in debug mode
Browser DevTools
Client-side code
Start the dev server (next dev) and open http://localhost:3000 in your browser.
- Chrome
- Firefox
- Open DevTools (
Ctrl+Shift+J/⌥+⌘+I) - Go to the Sources tab
- Search for files with
Ctrl+P/⌘+P
webpack://_N_E/./.debugger statements, or you can set breakpoints manually by clicking line numbers in the Sources panel.
React Developer Tools
Install the React Developer Tools browser extension for React-specific debugging:- Inspect component trees
- View and edit props and state
- Identify performance issues
Server-side code
Pass the--inspect flag to attach the Node.js inspector:
- npm
- pnpm
- yarn
- Chrome
- Firefox
- Open a new tab and navigate to
chrome://inspect - Find your Next.js app in the Remote Target section
- Click inspect to open DevTools
- Go to the Sources tab
webpack://{application-name}/./.Use
--inspect=0.0.0.0 to allow remote debugging from outside localhost, such as when running in a Docker container.