Home > Mobile >  React.js : How to run react.js code in two ports.? each component in one port
React.js : How to run react.js code in two ports.? each component in one port

Time:07-07

how to run react.js code in two localhost ports like one "component1.js" has to run on localhost:3000 port and second "component2.js" has to run on localhost:3001 port using the same React.js application please find the enter image description hereattachment.

CodePudding user response:

My solution: a custom node application which starts 2 http servers on 2 ports, with each one serving a component.js file.

CodePudding user response:

Run your app on two ports:

npm run dev -- -p 3000

And for the second:

npm run dev -- -p 3001

Then get the port number and redirect to the desired component.

  • Related