In the process of developing a Next.js application for users to download software, each software has its own unique download link. In order to achieve this functionality, I need to accomplish two specific tasks when a user clicks on the download link:
- Open the download URL in a new tab.
- Send an API request to my backend server to notify it that a user initiated the download process.
At this point, I am presented with two possible approaches:
a) Utilize a button element with an onclick event that triggers the function window.open("downloadUrl", "_blank", "noreferrer,noopener").
b) Incorporate the use of the Download attribute.
Furthermore, I aim to ensure optimal cross-browser accessibility for this feature.