Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda