// example url: https://mydomain.com/?fname=johnny&lname=depp const urlParams = new URLSearchParams(window.location.search); const firstName = urlParams.get('fname'); // johnny