You can use URLSearchParams and window.location.search
Example
First page link:
<a href="./second.html?product=coffee&productId=abc123">Coffee</a>
Second page JS
const params = new URLSearchParams(window.location.search);
const product = params.get('product');
const productId = params.get('productId');
Just be mindful about what you encode into the URL and how you use it. You can’t trust user input and the URL can be altered.