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
0
votes
0 answers

What are the pros and cons of using categoryID as dynamic route vs a unique categorySlug?

Suppose you have a simple case of a marketplace site, and you have different categories, like fruits, electronics, etc. I want to create a page for each category. My question is, is it better to use categoryId as the dynamic page name, or the…
Lei
  • 1
0
votes
1 answer

Updating data from Realtime database using getStaticProps

I have an application with markdown posts and comments taken from a Realtime Firebase database using getStaticProps. At first, I get all of the paths: export async function getStaticPaths() { const files = readdirSync('posts') const paths =…
0
votes
0 answers

Next js dynamic folder based routing

I am beginner in next js and i am trying to integrate dynamic folder based routing. For example if we want to create dynamic route we can use [id].js or [slud].js but i want to create routing like, /pages/[name]/index.js i tried many ways suggested…
0
votes
1 answer

nextjs dynamic routes doesn't work with next-i18next

I just added next-i18next in my nextjs project following the official guide and everything seemed to be in order, but when I change the language from default (Italian) to English and I go to the detail of an entity then I get 404. This happens only…
Loudrous
  • 1,039
  • 10
  • 29
0
votes
1 answer

Pass sensitive data to Nextjs Link component

I have a question about Link component from ‘next-Link ’ What should I do if I want pass a sensitive data like a category_id for example, how can I pass it securely to be used in getServerSideProps() function I don’t want want to use query string.
0
votes
0 answers

Module Federation Material shared dependency issue (Nextjs as host, React as Remote)

App Structure I'm using Next JS in Host app and React JS in remote app. Both apps are using below library as dependency Note I'm using ModuleFederationPlugin for both app and not using Next Js Specific module federation plugin Remote app…
0
votes
0 answers

SSR with cache:no-store option doesn't work - Next.js 13 App directory

I need data to be fetched on every request on server-side. I have the next route: office/[slug]/ > page.tsx Inside the page.tsx, I'm fetching the data with the cache:no-store option, because I need these data to be always fresh, but it keeps caching…
0
votes
0 answers

nextjs page contains a space is not triggered but /pages/page%20title does

i have this following structure under pages ├─ pages │ ├─ index.tsx │ ├─ betting │ │ ├─ [bet].tsx │ │ ├─ ippica live.tsx into index.tsx i have a next/link that redirects to ippica live, in the url i have…
majkl zumberi
  • 156
  • 1
  • 8
0
votes
0 answers

How to handle an array of bools from Body on a POST on nestjs?

Context: I have a list of presence, like in image: When I check few checkboxes and press 'Save' on POST the Body looks like that: This is as expected because html post will send only checked boxes. on backend I have this action in controller that…
Ovidiu Rudi
  • 191
  • 1
  • 15
0
votes
0 answers

Next.js: undefined props in URLs set in the rewrites of next.config.js

Hello very good morning, I'm building an App with Next.js and I'm facing the following problem. I want to get the data rendered from the client on a page and I have the following: // pages/news.jsx export default function News ({ title }) { …
0
votes
1 answer

Next.js getStaticProps params in context equal '[object Object]' / getStaticProps gets called multiple times

I am trying to understand why getStaticProps is getting called multiple times. The relevant file is called [postId].js in my pages/posts folder; code below: const MyPost({post}) => { // Main component in here } export default MyPost export async…
Fesch
  • 313
  • 1
  • 4
  • 12
0
votes
1 answer

Nextjs dynamic route page return 403 Forbidden error for only one specific user dynamic route

I have my route defined as patients/[userID].tsx in pages dir. When I tried to access one of the specific active userID (eg. patients/7917067d) it gave 403 Forbidden error in prod only, In dev, it is working fine. FYI, when I enter the wrong userId…
Rajat Verma
  • 420
  • 1
  • 7
  • 19
0
votes
0 answers

I need anyone who can help fix dynamic routing , server error in next.js using getstaticprops

[itemId] (https://i.stack.imgur.com/ObXBT.png) getting this Error: The provided path 1 does not match the page: /[itemCategory]/[itemId]. while trying to run the code
0
votes
1 answer

nextjs dynamic pages shows 404 after project hosted in ubuntu server

I've been working on this project for quite a long time now. Some of my dynamic pages have issues with 404 error even though they are running perfectly fine in localhost. I tried using revalidate and also fallback: true and false. But it seems not…
0
votes
0 answers

Next JS SSG Page shows "found page without a React Component as default export" while deploying in vercel

Just to mention that the answers in this Question did not work for me. So I have a page which used Static Site Generation(SSG) and no matter how i export it, while deploying in vercel the error always shows "found page without a React Component as…