getStaticProps is ignored or rejected in a Next.js project
"getStaticProps" is not a valid Next.js entry export valueShort answer
getStaticProps belongs to the Pages Router. Inside the app directory it is not used, and Next.js rejects it as an entry export. Fetch data directly in an async Server Component instead. If you do stay on pages, export it only from a page file, as a standalone function.
Fix it fast
1Find out which cause you have
Check which router the failing file belongs to. Files under app/ use the App Router; files under pages/ use the Pages Router.
grep -rn "getStaticProps\|getServerSideProps" app pages src 2>/dev/null2Match what you see, then jump to its fix
- 1
The page sits at app/.../page.tsx and the prop you expected arrives as undefined, or the type check names the export as invalid.getStaticProps is exported from a file inside app/Fix - 2
getStaticProps lives in pages/ but in a shared component, _app, _document or _error.The function is in a file that is not a pageFix - 3
The code reads Page.getStaticProps = ... or similar.getStaticProps is attached as a property of the componentFix - 4
getStaticProps runs (you see it in the build) but the page gets empty props.A custom _app drops pagePropsFix
- 1
What does the error look like?
"getStaticProps" is not a valid Next.js entry export valueHow to fetch data server-side in the latest Next.js? Tried getStaticProps but it's not running and getting undefined
Cause 1 of 4
getStaticProps is exported from a file inside app/
1Check
In the app directory the old data-fetching functions are replaced by a newer API built on async Server Components.
ls app && grep -n "getStaticProps" app -r2Fix
Delete the export, make the page an async function and fetch inside it. By default fetch is not cached; use the cache options to get build-time or timed behaviour.
// app/page.tsx
export default async function Page() {
const res = await fetch('https://api.example.com/items', {
cache: 'force-cache',
})
const items = await res.json()
return <ul>{items.map((i: { id: string; name: string }) => <li key={i.id}>{i.name}</li>)}</ul>
}3Verify
Build the project and open the route; the data renders without a props argument.
npx next buildConfirmed by nextjs.org
Cause 2 of 4
The function is in a file that is not a page
1Check
It can only be exported from a page. Look at where each export lives.
grep -rln "export .*getStaticProps" pages components2Fix
Move the function into the page file and pass the data down as props.
// pages/blog.tsx
export async function getStaticProps() {
const res = await fetch('https://api.example.com/posts')
const posts = await res.json()
return { props: { posts } }
}
export default function Blog({ posts }) {
return <p>{posts.length} posts</p>
}3Verify
Run the build; the page is prerendered with its props.
npx next buildConfirmed by nextjs.org
Cause 3 of 4
getStaticProps is attached as a property of the component
1Check
It must be exported as a standalone function; it does not work as a property of the page component.
grep -rn "\.getStaticProps *=" pages2Fix
Export it by name from the page module.
export async function getStaticProps() {
return { props: { ready: true } }
}3Verify
Restart the dev server; the page now receives the props.
npm run devConfirmed by nextjs.org
Cause 4 of 4
A custom _app drops pageProps
1Check
With a custom app, the pageProps must be passed to the page component.
cat pages/_app.tsx2Fix
Spread pageProps onto the page component in _app.
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}3Verify
Reload the page; the props arrive.
npm run devConfirmed by nextjs.org
How do I stop it coming back?
- In the app directory fetch in async Server Components; use fetch cache options in place of getStaticProps and revalidate.
- Use generateStaticParams in place of getStaticPaths for dynamic routes.
- Keep a short note in the repo saying which folders use which router.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
TypeScript rejects the authorize function of the Credentials provider
A custom field you return from authorize is missing on the User or Session type
The authorize callback must return either a user object or null.
3 causes, each with a fixWeb apps
The user is undefined inside the NextAuth session callback
session.user.id is undefined
With JWT sessions, NextAuth gives the session callback a token, not a user.
3 causes, each with a fixWeb apps
Upgrading to Next.js 16: middleware becomes proxy, and the other things that break
Missing Required default.js for Parallel Route
Next.js 16 renames middleware.ts to proxy.ts and its exported function to proxy.
6 causes, each with a fixWeb apps
next build stops because of TypeScript errors
How to disable typescript for failing my builds with nextjs?
next build runs a TypeScript check and fails the build when it finds type errors.
2 causes, each with a fixWeb apps
TypeScript cannot resolve import './globals.css' in Next.js
ts(2882)
TypeScript now checks imports like import './globals.css' when noUncheckedSideEffectImports is on, and it finds no type for a CSS file.
2 causes, each with a fixWeb apps
Type error after upgrading: params does not satisfy the PageProps constraint
Type '{ params: { id: string; }; }' does not satisfy the constraint 'PageProps'
Since Next.js 15, params and searchParams are Promises, not plain objects.
4 causes, each with a fix