// www.example.com/users?token=12345 let params = (new URL(document.location)).searchParams; let token = params.get("token"); // 12345