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

462
Views
How can I check if url parameters exist with formik register form? Is there a ready exported function that does this from formik?

I want to assign a value to one of the initial values (referrerId), based on whether URL parameters exist or not. I have left out the other code which I believe is irrelevant for this question. When the form loads, I want the referrerId field to be prepopulated with id extracted from URL parameters.

<Form
  initialValues={{
    referrerId: // if there are no parameters set string "none" : referrer's id, which is extracted from params,
  }}
>

   <FormField 
      label="Referrer's Id"
      name="referrerId"
      placeholder="Referrer's Id"
      type="text"
   /> 

</Form>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way to make this possible is by using the URLSearchParams javascript interface.

const parameters = new URLSearchParams(window.location.search);

<Form
  initialValues={{
    referrerId: `${parameters.get('referrer-id')}`,
  }}
>

   <FormField 
      label="Referrer's Id"
      name="referrerId"
      placeholder="Referrer's Id"
      type="text"
   /> 

</Form>

and your url will look something like

https://mycoolwebsite.com/somepage?referrer-id=23221
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!