Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
How to read the ref code from URL in react js

I want to get the ref code from the URL, http://localhost:3000/?ref=2926

I try with const session = ${window.location.href}; it gets the full current URL and tries to use split() the pathname but it didn't work, how to get only the ref code from the URL.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You also get value of ref from this way :

const queryString = window.location.search;
const parameters = new URLSearchParams(queryString);
const value = parameters.get('ref');
about 4 years ago · Juan Pablo Isaza Report

0

You may try this:

${window.location.search.split('=')[1]}
about 4 years ago · Juan Pablo Isaza Report

0

You can use browser native api

const query = new URLSearchParams(window.location.search);
console.log(query.get(ref))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!