Next.js connecting to Sanity CMS getStaticProps Error
Unanswered
Bull Arab posted this in #help-forum
Bull ArabOP
Hi Friends, I'm currently trying to display data from a sanity CMS using Next.js ,but i'm getting
getStaticProps is not supported in app/. below is a photo of my directory structure am i creating this page correctly ? I'm new to next.js and im just trying to wrap my head around this10 Replies
@Bull Arab Hi Friends, I'm currently trying to display data from a sanity CMS using Next.js ,but i'm getting `getStaticProps` is not supported in `app/.` below is a photo of my directory structure am i creating this page correctly ? I'm new to next.js and im just trying to wrap my head around this
you are in the app router, so getStaticProps is not supported, as the error says. either you use the pages router where getStaticProps does work, or you use the app router where you need to do it the app router way
Bull ArabOP
Hi @joulev thank you for the kind reply. I did more research and you're correct now i move the page route outside of the app route but now im getting 404 error
do you have any idea on how to get around this ?
@Bull Arab Hi <@484037068239142956> thank you for the kind reply. I did more research and you're correct now i move the page route outside of the app route but now im getting 404 error
You no longer have page.js files in the pages router
Check the routing documentation https://nextjs.org/docs/pages/building-your-application/routing/pages-and-layouts
Bull ArabOP
@joulev mhhm i see so im suppose to have an
page.js in order for the page route to work ?@Bull Arab <@484037068239142956> mhhm i see so im suppose to have an `page.js` in order for the page route to work ?
just read the correct documentation for the router you are using, the two routers have very different routing systems
depending on whether you use the app directory or the pages directory, you need different file names and follow different syntaxes
Bull ArabOP
ahh got it man thanks
i understand now