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

206
Vistas
Next.js how to getServerSideProps

for context I am in a folder in pages in a file named [id].jsx. How do I get getServerSide props to return the name of the page ex /page/id123 I want it to return id123.

import Link from 'next/link';
import React from "react";

export default function Global() {
        console.log(context)
        const address = useAddress();
        const disconnectWallet = useDisconnect();

        while (address) {
            return (
                <Link href="/">
                <a className="absolute pt-1 text-xl font-semibold transform -translate-x-1/2 top-1/2 left-1/2"> Click Here To Login</a>
                </Link>
            </>
        );
      }

export function getServerSideProps(context) {
    console.log("context: ", context.params)
    return {
        props: {context},
    }
}

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

0

Since your dynamic page is called [id].jsx, you can access that id in your getServerSideProps with: context.params.id.

export function getServerSideProps(context) {
    return {
        props: {id: context.params.id},
    }
}

Then in your component:

export default function Global({ id }) {
   console.log(id);
    ...

}

You can also access it using router object that comes from Next.js' useRouter hook:

export default function Global() {
   const router = useRouter();
   const { id } = router.query;
   console.log(id);
    ...

}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use ctx.resolvedUrl. It will either return what you want or you'll be able parse the needed part out

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