1

I have a button, this is called game. When this is clicked, routing is triggered and you are redirected to localhost:3000/game. However, I do not want to be redirected to a new page, but to a new React app. This app is in a different folder and was regenerated with npx create-react-app game. Is there an option to go to the new React app with this button click? The React app does not need to be started but only opened.

So when I click the button in my localhost:3000 the React App Game should open with the routing e.g. localhost:4000/game. Later, both React apps run on the same domain, for example, my-react-app.com and my-react-app.com/game

Is there such a thing? If so, how can I create it? Haven't found anything so far.

Larissa
  • 23
  • 2

2 Answers2

0

If you want to redirect to whole new port (i.e Other project) you need to use js or html href or window.open to do that there nothing here to use router. Router is used to navigate through the app or project not the whole web. thanks

Toxy
  • 521
  • 4
  • 7
0

You can use JavaScript functionality with window.location.href For example:

 const redirect = () => {
     window.location.href = "http://localhost:4000/game";
     };
   

Then call the function, for example using a button:

<button onClick={redirect}> Redirect </button>
programandoconro
  • 856
  • 1
  • 7
  • 19