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

191
Views
Nextjs getStaticPaths not generating paths in build time with dynamic routes

I am trying to go to /users/0 from /users page.

In /users/[id].js


export async function getStaticProps(context) {
  const { params } = context;
  const { id } = params.id;
  const transformedUsers = await getData();
  const foundUser = transformedUsers.find((user) => user.id === id);

  if (transformedUsers.length === 0) {
    return {
      notFound: true,
    };
  }
  return {
    props: {
      user: foundUser,
    },
  };
}

export async function getStaticPaths() {
  const transformedUsers = await getData();
  const ids = transformedUsers.map((user) => user.id);

  const pathsWithParams = ids.map((id) => ({ params: { id } }));

  return {
    paths: pathsWithParams,
    fallback: false,
  };
}

After I run the commands npm run build

└ ● /users/[id]                            298 B          82.4 kB

I am getting this in the console. But when I start the server with npm start and go to /users/0 i am getting 404 not found.

How to provide paths with getStaticPaths?

about 4 years ago · Juan Pablo Isaza
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!