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
1 answer

How to use fetch multiple api using using getStaticProps in next js

I have a [slug].js page where I'm using getStaticPath and getStaticProps to fetch the data and create static page{ export async function getStaticProps({ params }) { const { posts } = await hygraph.request( ` query…
Sujjeee
  • 15
  • 4
0
votes
0 answers

Downsides with a single NextJS catch-all route at the root level, for all CMS pages?

We are evaluating NextJS for an upcoming total rewrite of our frontend, and overall it looks quite promising. But the file centric or url-path-sentric routing gives us some headache. Our URLs are handled by the CMS. Here are some example…
0
votes
0 answers

How do i setting next.config.js rewrites with dynamic routing?

I use rewrites() to solve CORS error and it works , But dynamic routing does not work because of rewrites() - source & destination (I think dynamic routing does not work because of -> "/:path*" ) I expect no CORS error and Dynamic routing at…
0
votes
0 answers

Configure Google Cloud Platform bucket to serve example.com/page.html when user accesses example.com/page

I'm hosting a static (NextJS) site on a GCP bucket, with my domain CNAME (let's say example.com) pointing to GCP. When Javascript is disabled, NextJS links in my generated content point to URLs like: Page…
0
votes
0 answers

Dynamic Route in NEXTjs with sanity not working

I checked my code many times , also compared with people who have done the same project but i m still not able to undersatnd where my code is breaking down. There is no error as as byt even renderng using dynamic routes i get a 404 Here is my…
0
votes
1 answer

How to match URL path with array of predefined URL pattern using regex?

When I open my nextjs application, I will receive the current path details in _app.js. And I have a collection of possible URL patterns on my site. I need to match the current URL to the predefined patterns to identify which page is displaying—based…
Ajith Arasu
  • 79
  • 10
0
votes
0 answers

Facing issue while building next app using npm run build

Error occurred prerendering page "/actions/user". Read more: https://nextjs.org/docs/messages/prerender-error Error: Minified React error #31; visit…
user6021938
0
votes
1 answer

Returning data on page based on url query params

I am using Next.js Here is my file structure: --courses (folder) -course.js (file) --chapters (folder) -[chapter].js (file) I have a chapter called "hello-world" which will be in [chapter].js I want the route to be as follows:
0
votes
0 answers

path name is updating on refresh in nextjs dynamic routing

In my application on refresh pathname is getting changed as shown in the below SS can someone please suggest why is it happening like this?
Karthik
  • 51
  • 3
  • 8
0
votes
0 answers

How to make a nextjs component embeddable

I'm working on a project in nextjs in which I have created a dashboard in which users can manage their websites in groups, after this i have extracted data from the websites and the data is indexed in meilisearch for adding the search functionality,…
0
votes
1 answer

How can i nest child components in next js like react outlet?

I'm a react JS developer and trying to create nested childrens in nextjs. In react i used the outlet to nest the child components but how can i nest child in next js. Folder Structure: https://i.stack.imgur.com/IF32k.png Index.js:…
Sohaib Butt
  • 57
  • 1
  • 8
0
votes
0 answers

Open url link from lambda for cache html

I use nextjs with amplify and after deployment cache was reset. To save an HTML file to CloudFront cache it needs to be opened from browser. I use dynamic routes witch cache JSON (not HTML) in cache after navigating to page. Also i use lambda…
Ismeet
  • 419
  • 5
  • 19
0
votes
0 answers

How to render multiple pages using getStaticProps, getStaticPaths and json file

I am kind of new in all this stuff and I have a problem and I didn't have much of a luck in solving it. I have multiple segments with different title and content and I want to render a page for each segment that I have with the exact name how is it…
0
votes
1 answer

How to Remove Specific Query Filter From url in nextJS Application

i'm trying to add product filtering functionality like this: filter product image and after add filter i have to clear filter as user wish like this one: clear filter image if anyone give me real world idea with some more details or short word it…
0
votes
0 answers

Why js are not loading initial is coming while doing optimization I loaded js for once only in app

I loaded Google map and scripts in next js once in useEffect _app.tsx file instead _document.js file to avoid initial loading in order to increase responsiveness. When I am keeping open site for half n hour and refreshing - it is showing js not…