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

261
Visualizações
Identify the page from where we are navigating to the resulting page in Next.js

Let's say there are three pages - A, B, and C.

I can navigate from A to C and from B to C as well, but the view of C depends on the page from which we are navigating.

I would like to know how we can identify in Next.js from which page we are routing to page C.

Page C has a dynamic route

TIA

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could pass the previous location as query data:

<Link
          href={{
            pathname: "/some-page",
            query: "current location", // the data
          }}
>
         <a>Some Text</a> 
</Link>

Then you can retrieve the query data:

const router = useRouter();
const data = router.query;

If you don't like the idea of passing the previous location as a query, you could save the current location in a global state, like Redux on a page mount, after reading the previous value, which represents the previous location pathname.

about 4 years ago · Juan Pablo Isaza 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