You should definitely not use reduce() to format your search parameters! You should use the URL Object (linked below) and then modify or access the search params using the .searchParams property of that object.
// https://some.site/?id=123
const parsedUrl = new URL(window.location.href);
console.log(parsedUrl.searchParams.get("id")); // "123"
https://developer.mozilla.org/en-US/docs/Web/API/URL