I'm trying to use the WebStorm IDE debugger to debug a NextJS React app. I tried to use a JavaScript configuration, but that didn't seem to work -- neither when I used a Node config.
What's the correct procedure for debugging NextJS React apps with WebStorm?
Now go to the Debug panel ( Ctrl + Shift + D on Windows/Linux, ⇧ + ⌘ + D on macOS), select a launch configuration, then press F5 or select Debug: Start Debugging from the Command Palette to start your debugging session.
There are two main ways in which we can use them: By writing the debugger statement in our source code. By clicking on a specific line of the code in the Chrome web browser (or Firefox, Edge, etc.) Developer Tools.
The following steps work for me:
npm run dev
or whatever your start script looks like)http://localhost:3000
URLIf you like to debug the code that is executed on the server side, I'd suggest using the Node.js run configuration with node_modules\next\dist\bin\next
specified as Javascript file:
You can then debug both Node.js and Javascript Debug run configurations to get both server-side and client-side code debugged.
I found that clicking the play button next to dev
in package.json
and selecting the debug option worked for debugging my API served by Next.js.
This automatically creates the run configuration. Breakpoints are flakey though, I think because I'm using TypeScript. I need to edit the file after adding the breakpoint for them to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With