Hi,
On a dynamic routed page, I tried to migrate from getServerSideProps to getStaticPaths/getStaticProps to test SSG feature. But it does work. I get this error on page :
TypeError: Cannot destructure property 'publicRuntimeConfig' of 'next_config__WEBPACK_IMPORTED_MODULE_3___default(...)(...)' as it is undefined.
at getStaticPaths (/Users/jordid/GitHome/test-nextjs-config/.next/server/static/development/pages/todos/[id].js:174:5)
at buildStaticPaths (/Users/jordid/GitHome/test-nextjs-config/node_modules/next/dist/build/utils.js:18:86)
at Object.loadStaticPaths (/Users/jordid/GitHome/test-nextjs-config/node_modules/next/dist/server/static-paths-worker.js:8:140)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
type: 'TypeError'
}
No error at runtime
Afaik you cannot use Runtime Configuration with static pages, from the docs:
A page that relies on publicRuntimeConfig must use getInitialProps to opt-out of Automatic Static Optimization. Runtime configuration won't be available to any page (or component in a page) without getInitialProps.
You can use the build-time env vars instead: https://nextjs.org/docs/api-reference/next.config.js/environment-variables
Yeah as @rafaelalmeidatk said it's documented that this is expected not to work for static pages as they don't run at runtime.
Ah ok I did not see it. Thanks!
Most helpful comment
Afaik you cannot use Runtime Configuration with static pages, from the docs:
You can use the build-time env vars instead: https://nextjs.org/docs/api-reference/next.config.js/environment-variables