Invoices this opens a new tab. How do I do it for a new browser window ?" /> Invoices this opens a new tab. How do I do it for a new browser window ?" /> Invoices this opens a new tab. How do I do it for a new browser window ?"/>

How to open a link in new browser window using react router ? (not new tab)

3.2k Views Asked by At
<Link to="invoices" target="_blank">Invoices</Link> 

this opens a new tab. How do I do it for a new browser window ?

2

There are 2 best solutions below

1
leo_sheecool On

You can do window.open in a onClick, here's the documentation https://developer.mozilla.org/en-US/docs/Web/API/Window/open

0
jsejcksn On

As a hack (and I mean that genuinely), you can accomplish this in browsers which support the shift + click gesture to open a new window by using this for the onClick function of the anchor element:

(event) => {
  event.preventDefault();
  event.target.dispatchEvent(new MouseEvent('click', {shiftKey: true}));
};

I tested it against Chrome desktop only.