Questions tagged [getstaticprops]
90 questions
1
vote
0 answers
How to share staticProps across Components in nextjs
Im trying to build a website using nextjs. I thought it was a good pick for what im trying to do, but now im stuck.
I have a single api endpoint i want to call and fetch some static data. But the problem is that i need parts of the data all over my…

user3086509
- 117
- 1
- 8
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
0 answers
next-i18next useTranslation without getStaticProps
My problem is that I can't make translations to work outside a regular page component.
The only case that works is when I use getStaticProps.
Example that works just fine:
import {useTranslation} from 'next-i18next';
export async function…

YiazmaT
- 1
- 1
0
votes
2 answers
getStaticProps not sending data to page in Next.js
I'm trying to figure out why my getStaticProps is not sending any data. When I log the Home page props, it shows posts as undefined. I'm new to Next.js
Here's my code
export async function getStaticProps() {
const response = await…

Davina Leong
- 737
- 2
- 11
- 28
0
votes
0 answers
Global Revalidate value | X is not a valid. The configuration must be statically analyzable
Does anyone know how to use global config for Nextjs?, I'm using the new App Router (./app), before this new router this code worked
constants.ts file
export const REVALIDATE_ITERATIONATION: number = 1800
page.tsx file
export const revalidate =…
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
0
votes
1 answer
Undefined return value from getStaticProps
The value being returned from my getStaticProps in nextjs is undefined. I tried fetching data from a graphql endpoint and the return value was undefined when I console.log the value. This is the code block
const graphQuery = new…

Ayo Niyi
- 1
- 1
0
votes
1 answer
Can't figure out why getStaticProps isn't loading before main exported function
I am using npm run dev to debug this, which uses getStaticProps to process a number of d3 props before injecting it into the main output function at runtime. As far as I can tell, getStaticProps isn't running - a console.log inside it to retrieve…

Reuben
- 81
- 9
0
votes
2 answers
Error: Export encountered errors on following paths: "/". When trying to deploy Next.JS project
I am trying to deploy my nextJS project however the console keeps returning this error
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
SyntaxError: Unexpected token < in JSON at position 0
at…

Thenamesoak
- 43
- 6
0
votes
1 answer
Why is my NextJS function 'getStaticProps' not running?
The main reason I'm using Next is the 'getStaticProps' function and it's not even running.
I tried to create a new app from scratch "npx create-next-app@latest" not working, I tried "npx create-next-app" without the "@latest" still doesn't…

Hamza
- 3
- 1
0
votes
1 answer
Intersection observer only works with the last element in Next.js
Intersection observer only works with the last element in Next.js
I want to target all the repeated div elements and put an opacity effect(0 or 1) every time I see them on the viewport, but only the last div element ends up having the opacity…

rolly89
- 1
- 3
0
votes
0 answers
How to create a Vercel Cron job for getStaticProps in NextJS?
I have a NextJS website that has 6-7 API that needs to be called every 24 hours. Earlier I was using ISR with revalidation but someone suggested using Vercel's cron job.
I need to set it up so that the getStaticProps function is triggered every 24…

Ankit Sharma
- 164
- 8
0
votes
0 answers
getStaticPaths works in development mode but not in netlify? How to handle more static pages?
I'm trying to build SSR application which generates static pages to display pokemon 0 to 160 showing 20 per page, so to do that I'm using getStaticPaths.
It works in development mode (npm run dev) but when I acess the '/products/1 to /8' in netlify…

Higor456
- 19
- 4
0
votes
1 answer
How to fix "TypeError: Cannot read properties of undefined (reading 'length')" in nextjs?
enter image description here
I guess getStaticProps doesn't work well, but I don't know exact..
Is getStaticProps render after render Main function?
below code is index.js
import Main from "../components/main/main";
export default function Home()…

sssss
- 3
- 1