Next.js Discord

Discord Forum

Using getStaticProps

Unanswered
Whippet posted this in #help-forum
Open in Discord
WhippetOP
Hi, i'm a rookie in next.js and im trying to use getStaticProps inside a page file,
but at the the temp argument im sending in the getStaticProps is undefined.
can anyone please look and see what im doing wrong

11 Replies

WhippetOP
@joulev Because the code looks correct if it is in the pages router
WhippetOP
what do you meant the app router? im using it inside a page.jsx inside the app folder
Cinnamon
@Whippet maybe try learning with the page router first as it is what most people are using
@Cinnamon <@379257610395844608> maybe try learning with the page router first as it is what most people are using
WhippetOP
i'm sorry i'm a bit new to next.js can you please send the link of the documentation of what you referring ? my end goal is to build a component at the server side using data from a json file
Cinnamon
Sure no problem, if you take a look at the NextJs docs , top left you can see a button that switches between the page router and the newly added app router , here's what you are looking for : https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props
WhippetOP
thanks you, things are starting to make sense now 👍