0

So I'm making a Next.js app where users can download software. Each software has a download link. If a user clicks download I want to do 2 things:

  1. Open the download URL in a new tab
  2. Make a API request to my backend to let it know that a user clicked download

So now im left with 2 choices:

a) Use a button with onclick of window.open("downloadUrl", "_blank", "noreferrer,noopener")

b) Use Download

I also would like to have the most across browser accessability.

1 Answers1

0

For maximum accessibility, I recommend you instead use an anchor tag with an onClick method (this strategy is mentioned in this losely related question).

If you're using JSX:

<a title="Some title for accessibility" href="http://downloadlink.com" onClick={()=>sendPingToServer()}>Some Text</a>
IndevSmiles
  • 737
  • 6
  • 17