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

400
Vistas
How to dynamically change URL in a Next.js application without using <Link>?

I know it's possible to dynamically change the URL without refreshing the page by using <Link>; however, is it possible to do so without <Link>? For context, I'm trying to change the URL dynamically on a page to another one if a variable changes its value from false to true. The variable's value isn't dependent on a button being clicked on, so that's why I don't want to use <Link>. At the moment, I'm using window.top.location.href inside of a useEffect(), which gets the job done — but it's very clunky since the entire page reloads. Does anyone know how to achieve what I'm trying to do?

The following is what I'm currently doing:

useEffect(() => {
  if (status === true) {
    window.top.location.href='https://www.website.com'
  };
}, [status];
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I figured out a solution. All I needed to do was swap out the line with window.top.location.href to router.push(). The following is the updated code that works as intended:

useEffect(() => {
  if (status === true) {
    router.push('https://www.website.com')
  };
}, [status];
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