Questions tagged [getstaticpaths]

34 questions
2
votes
0 answers

Is performance impact when `getStaticPaths() fetching all posts, which posts total are a million posts?

export async function getStaticPaths() { // Call an external API endpoint to get posts const res = await fetch('https://.../posts') const posts = await res.json() // Get the paths we want to pre-render based on posts const paths =…
Danar Widi
  • 21
  • 2
  • 3
1
vote
0 answers

Nextjs getstaticpaths in build time tries to render un existing paths

Now this is my situation: My file structure: My UI structure: So, when i access the routes outside "Folder 1" ( [docsSlug].js ) (Home, Article 1, Article 2, ...) they work fine but when i go inside the folder on "Catch All Routes" (…
Ilir
  • 488
  • 5
  • 20
1
vote
1 answer

Next.js getStaticProps doesn't run and on next build shows error

import { medusa } from "@/app/requests/medusaClient"; import { useState, useEffect, JSXElementConstructor, PromiseLikeOfReactNode, ReactElement, ReactNode, ReactPortal } from "react"; import { Product} from "@/app/models/productModel"; import {…
1
vote
0 answers

Where should I export server code in nextJS in case of code splitting?

In a nextJs project connected to mongoDB, I have multiple database connection in multiple getStaticProps and getStaticPaths functions. The code works but is repeating multiple times in my project : const client = await…
Keitaro
  • 93
  • 2
  • 11
1
vote
1 answer

Firebase/NextJS: Can't access subcollections for dynamic routing

I'm building a story editor where you can write stories and separate them into different chapters and I'm having trouble accessing my subcollection for NextJS's "getStaticPaths" because every document is a UUID. I have data stored in a Firebase…
1
vote
0 answers

Next.js getStaticProps/getServerSideProps best use case

I have a blog that is using getStaticProps + getStaticPaths to generate pages from headless WP - all good. Then I have a component that is connecting to the database to allow me to link to the next post in any within any individual category. This…
1
vote
1 answer

NextJs getStaticPaths not rendering the appropiate page, shows 404 error

Okay this may be a very stupid question but I have never used 'getStaticPaths' before but for this project I really need too! I have used the code of NextJs's documentation on 'getStaticPaths' and while the code compiles correctly when I head to…
MatDoak
  • 132
  • 5
  • 17
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

how to rename and save extracted pages with JavaScript

I have a 28 page pdf file. I would like to create a button that allows me to extract page 5 and rename it before saving it in the documents folder. With another button, I would like to email as an attachment page 5 renamed. I created this…
Tabene
  • 11
  • 2
1
vote
1 answer

Do I need to use revalidate key in getStaticProps Next.JS for lists in page?

I'm making static e-commerce app with Next.JS. I have products directory with index.js and [id].js files. Do I need to use revalidate: someTime in products/index.js file which returns list of all products for keeping list up to date? Or it's feature…
andrewnosov
  • 374
  • 4
  • 14
1
vote
1 answer

Next.js 9.3+ and catch-all routes

Next.js beginner here, hoping for pointers on using getStaticPaths and getStaticProps with catch-all routes. Most Next.js 9.3+ blog starters seem to be based on just one level of blog posts (e.g., /posts/post-1.md, /posts/post-2.md, etc.), but what…
Bryce Wray
  • 285
  • 3
  • 12
0
votes
1 answer

Handle dynamic routing when the paths are coming from supabase

I'm building a blog and I'm wondering how should I handle the getStaticPaths if the blogs are stored at Supabase... The blog will have thousands of entries someday. How can I handle the supabase limits? Now, my code goes like this. export const…
Emiliano
  • 437
  • 1
  • 4
  • 14
0
votes
0 answers

Is it possible to use `getStaticPaths` to build static files such as JSON content inside the public folder? (Next.js)

It is well known that you can serve static files (e.g., JSON, CSV, etc.) in the public folder of a Next.js project (e.g., public/data/MyData.json). It is also well known that you can have pages with wildcard names (e.g.,…
0
votes
1 answer

Having trouble prefetching data in Next.js

I have a simple dummy API that returns an array of objects dummy data such as: // api/projectsdata.js export default function handler(req, res) { res.status(200).json([{...},{...},{...}] } My fetch API looks like this: import {…
Roma Kim
  • 321
  • 1
  • 8
0
votes
1 answer

Next.js 13 getStaticProps trouble with data fetching (newbie)

I'm newish to Next.js and the rest of React and was using it (and Tailwind CSS) on a project. I was working with getStaticProps to grab data from a json file and display different sections of it on different pages using dynamic routes. I have much…
SuperNunb
  • 133
  • 2
  • 13
1
2 3