Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda