Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!