VS Code

How to Debug React App in VSCode Easily

How to Debug React App in VSCode Easily

Debugging a React app in VS Code mostly comes down to having a launch.json file and a dev server that’s running. You generate the file from the Run and Debug view. Then you press F5, VS Code opens a browser with the debugger attached, and it stops at your breakpoints with props, state and the call stack visible inside the editor.

You don’t need an extension for any of this. The 2026 VS Code documentation states that the built-in JavaScript debugger handles client-side React code, with no extension required for Edge or Chrome. If a tutorial still has you install Debugger for Chrome, it’s old.

It works the same whether the project started from Vite, Next.js or Create React App.

How to Set Up the VS Code Debugger for a React App

YouTube player

I’m following the 2026 VS Code React tutorial here. It says its steps still apply to any React project setup, and in practice that’s been true.

  1. Start the dev server with npm start (Create React App) or npm run dev (Vite), and leave it running.
  2. Open Run and Debug. That’s Ctrl+Shift+D on Windows and Linux, or Shift+Cmd+D on macOS.
  3. Click “create a launch.json file”, then pick Web App (Edge) from the Select debugger dropdown. VS Code writes .vscode/launch.json.
  4. The generated config points at port 8080. Change the url to your dev server address, such as http://localhost:3000.
  5. Set a breakpoint by clicking the gutter left of a line number inside a component file.
  6. Press F5. A browser window opens with the debugger attached.
  7. Click the button or load the route that runs that line.

The dev server has to stay up in the integrated terminal while the debugger runs. If the panel is hidden, this guide to opening the terminal in VS Code shows the shortcut.

One thing that confuses people early on. Code that runs at startup executes before the debugger attaches, so a breakpoint there stays silent until you refresh the page.

Do You Still Need the Debugger for Chrome Extension?

No. Search results disagree on this, and the age of the page usually explains why.

DigitalOcean’s Create React App guide says to install the Debugger for Chrome extension first. There’s a Scotch.io copy of that same guide, and it carries a note that it is out of date and no longer maintained. The current VS Code documentation covers Edge and Chrome with the built-in debugger and no add-on.

Firefox is the exception. Its debugger still ships as a separate extension, firefox-devtools.vscode-firefox-debug.

What Each launch.json Setting Does

When a React debug session misbehaves, the cause is almost always in a handful of fields. Here’s what each one controls and the value I’d start with.

SettingWhat it controlsTypical React value
typeWhich browser debugger startsmsedge or chrome
requestConnection modelaunch (new browser) or attach (running browser)
urlPage the browser openshttp://localhost:3000 for Create React App, http://localhost:5173 for Vite
webRootFolder used to resolve source maps${workspaceFolder}, or the app subfolder in a monorepo
skipFilesFiles that stepping passes overglob patterns such as **/node_modules/**

For a Vite project, this is enough:

{
"type": "chrome",
"request": "launch",
"name": "Debug React in Chrome",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}"
}

Watch the port, though. Vite’s default server.port is 5173, and if that port is busy Vite moves to the next free one unless server.strictPort is on. A url pinned to 5173 then opens the wrong page or nothing at all (per the Vite 8.3 documentation). Easy to miss when you have two projects running.

webRoot defaults to the workspace folder and is used for source map resolution. In a monorepo, point it at the app folder instead, as a Create React App sample does with “${workspaceFolder}/react-cra”.

Choosing Chrome or Edge as the Debug Target

Either one works. To use Chrome in a launch config, replace msedge with chrome.

The Debug: Open Link command makes the choice on its own. It goes with Edge if that’s your default browser, and otherwise it looks for Chrome.

I’d pick whatever browser your team tests in. The debugger behaves the same on both.

Keeping Library Code Out of Your Stepping Path

Step into a state setter and you can end up deep inside library code that has nothing to do with your bug. Annoying, and it happens a lot.

The skipFiles attribute controls stepping and skipping behavior. Add a node_modules glob and the debugger passes over those frames, so F11 stays in code you wrote.

Breakpoints and Stepping Controls for React Components

VS Code supports line, conditional, triggered, inline, function and data breakpoints plus logpoints. For React, line and conditional breakpoints do most of the work, and logpoints come in handy more often than you’d expect.

  • A line breakpoint goes on with a click in the editor margin, or F9.
  • Conditional breakpoints pause only when an expression is true or after a set hit count. Triggered breakpoints are related, and they wait until another breakpoint is hit.
  • Logpoints write a message to the Debug Console without pausing, using {expression} syntax such as User ID: {user.id}.
  • Inline breakpoints (Shift+F9) pause at a specific column, which helps in minified code.

ProfyDev’s React walkthrough puts a conditional breakpoint on an issue row component with the expression issue === null, so the debugger skips every render where the data is fine.

Breakpoints behave the same for any bundle, so the wider habits of debugging JavaScript (reproduce first, narrow with a condition, then step) apply here too.

Exceptions get their own toggles in the Breakpoints panel. Switch on caught or uncaught exceptions and the debugger stops at the throw instead of at the console error, which saves a lot of scrolling back through a stack trace.

Once you’re paused, these keys move you around:

  • F5 continues to the next breakpoint
  • F10 steps over a line, running function calls without entering them
  • F11 steps into a call
  • Shift+F11 steps out

In a click handler, F10 moves past a setCount call. F11 on a call to your own helper enters that helper.

How to Inspect State, Props and Hooks While Paused

The Variables panel shows locals and globals for the selected stack frame. In a function component, props and hook return values appear there as ordinary variables.

Variables, Watch and Call Stack

  • You can edit a value in Variables with Set Value (F2 on Windows and Linux) and test a fix without touching the source
  • Watch evaluates your expressions again at every pause
  • Call Stack lists active function calls. Selecting a frame loads that frame’s variables

Evaluating Expressions in the Debug Console

The Debug Console is a REPL that evaluates expressions in the selected stack frame. Type props.items.length while paused and the answer comes back without a code change.

Open it with Ctrl+Shift+Y on Windows and Linux. Shift+Enter gives you multiline input. It only works during an active debugging session.

Hook values show up as plain variables. That confirms what useState returned on a given render, but not why the render happened, so a refresher on how hooks keep state between renders helps when values look stale.

What you won’t get is a component tree. Questions about which component re-rendered or what a parent passed down belong to React Developer Tools, a browser extension built for that.

Should You Launch or Attach the Debugger?

Launch starts a new browser instance for you. Attach connects to a browser that’s already running in debug mode, like one you keep open between sessions or one on another machine.

Launch

Once the config exists, launch is one keypress and there are no browser flags to remember. The config also lives in the repo, so teammates get it without asking.

The downside shows up every single session. A new browser instance opens, which adds startup time and drops your open tabs. It runs on a separate profile too, so your everyday logins and extensions aren’t there and signed-in pages need a fresh sign-in.

Attach

Attach gives you more control. The url option attaches only to tabs with that URL (without it, all tabs are attached), and the address option reaches a browser on another machine. The debug browser stays open when the session ends, so its tabs and sign-ins carry over to the next one.

Setup is where it gets fiddly. The browser must start with –remote-debugging-port=9222, and the port in launch.json has to match. It also needs a separate –user-data-dir. Since Chrome 136, the remote debugging flag is ignored on the default profile, so you can’t attach to your everyday profile. Leave the flag off and the command just opens a window in the already running browser, which doesn’t enter debug mode.

An attach entry for a Create React App project:

{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}

You can also skip launch.json entirely. The Debug: Open Link command attaches to a URL you enter, and clicking a link in the JavaScript Debug Terminal starts a session.

My default is launch. Attach is worth the extra setup only when you want a long-lived debug browser or one running on another machine.

Debugging Vite, Create React App and Next.js Projects

The launch.json barely changes between toolchains. Vite and Create React App differ only in the url. Next.js is the odd one, because its server-side code needs a second configuration.

Vite

When the dev server starts, Vite prints a Local address in the terminal. Copy that into url. It settles the port question whenever Vite has moved off its usual port.

Create React App

The React team announced the sunset on February 14, 2025, and recommended Next.js, React Router and Expo for new apps. Their stated reason was that Create React App has no active maintainers.

The 2026 VS Code React tutorial agrees. It says Create React App “is no longer actively maintained” and points you to Vite or Next.js instead.

An existing Create React App project debugs exactly as before, with no launch.json changes. For a new project, start from Vite or a framework.

Next.js: Client and Server Code

Next.js renders in the browser and on the server, so a single browser-style configuration only covers half the app. The Next.js debugging guide (updated August 25, 2026) gives one entry for each side plus a combined one.

  • The client-side entry uses type chrome, request launch, url http://localhost:3000
  • Server-side is type node-terminal with the command npm run dev — –inspect
  • For full stack, a node configuration runs the next binary with –inspect, then opens Edge through serverReadyAction (debugWithEdge, or debugWithChrome for Chrome) once the server reports ready

In a monorepo such as Turborepo, add cwd to the server-side and full-stack entries, for example ${workspaceFolder}/apps/web.

To pause on the first server line, –inspect-brk and –inspect-wait go through NODE_OPTIONS instead, as in NODE_OPTIONS=–inspect-brk next dev.

Why Breakpoints Do Not Hit and How to Fix Them

A hollow gray breakpoint means VS Code couldn’t register it. Hover over it and you’ll see “Breakpoint ignored because generated code not found (source map problem?)”, which tells you where to look first.

SymptomLikely causeFix
Hollow gray breakpointSource map does not resolve to your fileCheck that sourceRoot and sources form a valid path, and that webRoot points at the app folder
Page loads, nothing pausesurl or port in launch.json targets another serverMatch url to the address the dev server printed
Pauses inside bundled or minified codeBuild output has no source mapEnable source maps for the build
Worked before the folder was movedwebRoot still points at the old locationUpdate webRoot to the folder that holds the sources

Production builds are a common trap here. Vite’s build.sourcemap option defaults to false, so a production build ships without a map until you set it to true (Vite 8.3 documentation).

Source Map Checks That Catch Most Cases

  • Confirm the source maps exist, either as .js.map files or inlined in the .js files.
  • Check the letter casing of the folder you opened in VS Code. The wrong case can block source map resolution, and it took me far too long to learn that one.
  • Only source maps inside outFiles are resolved by default. Use resolveSourceMapLocations to include others, such as maps shipped with dependencies.

Still stuck? Run Debug: Diagnose Breakpoint Problems from the Command Palette for hints. The trace attribute, supported in both launch and attach configurations, adds diagnostic output.

Debugging Jest and Vitest Tests in VS Code

Tests run in Node, not in a browser, so the configuration switches to type node and drops url and webRoot. Jest and Vitest get there differently.

Breakpoints inside a test pause the same way they do in the browser, and the Variables, Watch and Call Stack panels work unchanged. That makes unit testing a practical place to reproduce a bug before touching the UI.

Jest

Jest runs with –inspect-brk and –runInBand. The first flag pauses Node until a debugger connects. The second keeps every test in one process, which matters because Jest normally spreads test files across worker processes, and stepping through many processes at once is hard.

This launch.json entry starts Jest under the debugger:

{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}

On Windows, point runtimeArgs at node_modules/jest/bin/jest.js instead. Create React App projects run react-scripts test with –runInBand, –no-cache, –env=jsdom and –watchAll=false.

Component tests written with React testing libraries render in jsdom, so a breakpoint inside the component pauses in the Node process. A debugger; statement in the test also pauses execution when Jest reaches it.

Vitest

The quickest way in is a JavaScript Debug Terminal. Open one and run npm run test or vitest directly.

If you’d rather click, the official Vitest extension has a Debug Tests button. There’s also the launch.json route: a node configuration with program set to node_modules/vitest/vitest.mjs and args [“run”, “${relativeFile}”], which runs the open test file.

Vitest recommends –test-timeout=0 so a test does not time out while paused at a breakpoint.

The same tip also recommends –no-file-parallelism, and the Node Inspector section explains why: debugging requires tests not to run in parallel. The VS Code launch.json example leaves the flag out, so add it to args when a breakpoint should survive across several test files.

VS Code Debugger, React Developer Tools or console.log: Which to Use

They don’t really compete. Each one answers a different question, and once you know which question you’re asking, the tool is usually obvious.

The VS Code debugger is for reading state at one exact moment. Logic errors, wrong state values, control flow that goes somewhere you didn’t expect. Pause, step, and read the Variables panel.

React Developer Tools is about structure. Its Components panel lets you inspect components and view and edit props and state, and the Profiler panel finds performance problems. The browser extension exists for Chrome, Firefox and Edge, and Safari users run the standalone react-devtools npm package. The Profiler tells you where renders are slow. Fixing them is a separate job, covered in guides on React performance optimization.

And console.log still has a place. I reach for it with timing-sensitive code, because a breakpoint freezes the page and distorts animations, timers and race conditions. A log line leaves the timing alone.

The debugger is also a poor first move for a bug that shows up only in a deployed build. The launch configuration targets your local dev server, so it never sees the production bundle.

For anything that’s wrong and reproducible locally, the debugger is my default.

FAQ About Debugging a React App in VS Code

Can you debug a production build in VS Code?

Yes, if you serve the build locally and it ships a source map. Vite’s build.sourcemap accepts true or ‘inline’, but ‘hidden’ suppresses the sourcemap comments in the bundled files, so the debugger has no pointer to the map.

How do you stop the dev server from opening an extra browser tab while debugging?

Launch mode opens its own debug browser, so a second tab is redundant. Vite opens a tab only when server.open is set, so leave it off. For Create React App, start the server with BROWSER=none.

Does the same setup work for React Native?

No. React Native apps don’t run in a browser, so the chrome and msedge configurations don’t apply. From React Native 0.76, the built-in React Native DevTools is the debugger for apps running Hermes. It replaced the older Flipper, Experimental Debugger and Chrome-based Hermes debugger frontends.

Can you debug a React app in GitHub Codespaces?

Yes, but not from the browser editor. Browser code there can’t launch another browser in debug mode. Open the codespace in desktop VS Code instead, which uses a companion extension to launch your local Edge or Chrome.

In the web editor, step over becomes Alt+F10 instead of F10, and on Windows browsers step into becomes Alt+F11 instead of F11.

Can you debug React inside VS Code without opening Chrome or Edge?

Yes. Set the launch configuration type to editor-browser to debug in VS Code’s integrated browser, with no external browser window involved.

Sharing a React Debug Configuration with Your Team

Commit .vscode/launch.json to the repository and every teammate presses F5 and lands in the same debug session. Project-specific configurations live in that file at the workspace root.

Start with paths. Use ${workspaceFolder} only, because an absolute path breaks on the second machine.

Then pin the dev server port, since a shared url stays valid only while the port holds. Setting server.strictPort makes Vite fail instead of drifting to the next free port. I’d rather get a clear error than a debugger quietly pointed at the wrong server.

After that, add an entry for each browser the team uses. A mixed team needs both a msedge and a chrome entry, so the file gets longer and the launch dropdown grows by one. Worth it.

Staging and pushing the folder follows the usual steps for committing changes to GitHub. Check that .gitignore does not exclude .vscode.

This advice holds as of November 20, 2026, against the VS Code 2026 React tutorial and the Vite 8.3 documentation.

Bogdan Sandu

Stay sharp. Ship better code.

Every week: one curated article, one tool worth knowing, one tip you can use tomorrow. No noise, no padding.