Questions tagged [nextjs-dynamic-routing]

In Next.js, dynamic routes are defined by placing the parameter inside square brackets ([]) in the page file name. For example, if you have a dynamic route for displaying a user's profile, you can create a file called [username].js. The username inside the brackets is the parameter that will be used to generate dynamic pages.

To handle dynamic routes, Next.js provides a special component called getServerSideProps or getStaticProps. These functions allow you to fetch data based on the dynamic parameter and pass it as props to the page component.

188 questions
1
vote
1 answer

Daynamic routing page in not coming, when use browser back button in next js

In a Next.js project, I am coming across a situation where I get a new URL path from an API. And I have to update that URL path in the browser without reloading that page. I am doing that with the help of…
1
vote
0 answers

Dynamic data fetching in dynamic pages (Next.js and Redux Toolkit)

In this dynamic page, we have to fetch different APIs by coming from different routes. I want to dynamically fetch and list not only fetchProducts, but also crops from any data on this page. For example: How should we do this? the code you see is…
1
vote
1 answer

Access json data based on dynamic route nextjs

I have a json file that contains content for several different pages that are under a "service" category. I use dynamic routes in nextJS by having a file as "[serviceId].tsx", this routing works. However I have a json file where I want to use the…
Tihi
  • 27
  • 4
1
vote
0 answers

cannot find the data from mongodb/mongoose in next js

hey i'm trying to fetch the multiple data from mongodb in mongoose with different id's but i get unkown error i try few different different approach but nothing works for me fetcing the data let ids = []; for (let i = 0; i < itemforbuy.length;…
z Hunter
  • 31
  • 4
1
vote
0 answers

Project is not deploying project in vercel

when I deploy my project to vercel its shows me an error. when I just command enter code here"npm run build" in the terminal its shows ○ (Static) automatically rendered as static HTML (uses no initial props) but I don't understand what the…
1
vote
1 answer

NextJS static pages never get refreshed in browser although revalidated on server

I have a NextJS project with many sites that use getStaticProps() in combination with revalidate. As expected, the pages are generated at build time and are rebuilt in the specified interval (verified using a REST client). However, the users never…
1
vote
1 answer

NextJs Dynamic Folder Routing

Im trying to achieve a case where you have two seperate navbars, views-nav with links "results", "statistics" and schools-nav with links "school-a", "school-b", "school-c"... The url would look something like this when user first lands: …
1
vote
0 answers

how to rendering the root page in nested routes in Next.js

This is my dir structure on Next.js app: pages |-users | |-index.js | |-[userid] | |-index.js index.js when I call domain.com/users/1 I want the users->index.js component to be rendered as well. it only renders the…
1
vote
3 answers

Create dynamic routes by id from Next JS pages api

I have a page with a list of objects called stories that displays all my stories in an array. I also have a detail page with displays an individual story. I want to click on a link on any given story on the list, then it will navigate me to the…
1
vote
0 answers

NextJS - how to dynamically load different apps with dynamic routes

I have a multi-lingual application that I use exportPathMap but I want to transition to getStaticProps and getStaticPaths. My structure looks like so: pages/[language]/[app-slug].js However, [app-slug].js could be any of 20 different applications…
Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
1
vote
1 answer

Warning Prop `href` did not match

I have a dynamic page route after another dynamic page route. I'm only getting this warning for the second dynamic page route. Warning: Prop `href` did not match. Server: "/books/category/[category]/filter/[filter]#" Client:…
1
vote
0 answers

NextJS route gives 404 when not using Link

I have a Next.js page, where the pages are statically generated (using next export). It's a dynamic route, but I will only fetch data on the client after the initial page load (in a useEffect). The path is something like: /pages/foo/[id].tsx. This…
Nix
  • 5,746
  • 4
  • 30
  • 51
1
vote
2 answers

Next.js setting current active class with Link and router

I wanted to set an active class to the current page, but I'm missing something.
hellomello
  • 8,219
  • 39
  • 151
  • 297
0
votes
1 answer

Mocking dynamic route params in Next 13 app dir

I'm using Jest and testing library to run unit tests on my NextJS app but struggling to figure out how to render a page on a dynamic path. For my page/component: export default async function MyPage({ params }: { params: { id: string }}) { …
0
votes
0 answers

Issues with Next.js 13 Dynamic Routes Generating .txt Instead of .html for New Products

I'm facing an issue with my Next.js 13 application's router involving dynamic routes and the generation of static pages. I've successfully implemented a dynamic route to fetch a single item using its product ID, utilizing generateStaticPaths.…