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

637
Vistas
Is there an equivalent for {useLocation} from 'react-router-dom' in nextjs

import { useLocation } from 'react-router-dom';

I'm currently using Nextjs, I need help for an equivalent of useLocation

`

 import Link from 'next/link';
 import { FC } from 'react';
 import {useRouter} from 'next/router';
 import { useStore } from '../store';`



const PrivateRoute: FC = ({ children }) => {
const currentUser = useStore((state) => state.currentUser);
const location = useRouter();`

if (!currentUser)
    return (
        <Link
            href={`/sign-in?redirect=${encodeURIComponent(
                location.pathname + location.push('chat')
            )}`}
        />
    );
return <>{ children }</>

}

export default PrivateRoute;`

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can use useRouter from 'next/router' and then you can either use pathname or asPath and then you conditionally add slug or params. Rest you can find more information via documentation posted by others.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Yea you can use useNavigate in react-router-dom v6 and you can use useHistory in react-router-dom < v6

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