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

126
Views
Next.js Query param get lost on page refresh

I have 2 components and i need to route between them and passing data from the first to the second and not send the param in the url. but my problem is when I refresh the page the query params get lost.

 <p className={styles.jobname}>
        <Link
          href={{
            pathname: `alyDeal/` + `${jobId}`,
            query: {
              jobName,
              desc,
              subcat,
              city,
              est,
              bids,
              userId,
              name,
              picture,
              jobId,
              jobImages,
              budget,
              neigh,
              score,
              phone,
              email,
              deadline,
              jobAddress,
              createdAt,
              ownedBus,
              category,
            },
          }}
          as={`/alyDeal/${jobId}`}
          passHref={true}
        >
          {jobName}
        </Link>
      </p>

and in the second component

export const getServerSideProps = async (context) => {
  {
    const { query } = context;
    return { props: { query } };
  }

const { query } = props;
  console.log(query);

and the query always returns only the id that I'm passing directly into the URL but not the rest of the query object

Any solutions? };

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Why don't read the query directly in the page? You don't need to use props.

function MyComponent() {
  const router = useRouter()
  const { query } = router

  // use the query data

  return (
    <div>JSON.stringify(query)</div>
  )
}
about 4 years ago · Santiago Gelvez 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!