question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot destructure property `serverRuntimeConfig` of 'undefined' or 'null'

See original GitHub issue

Can serverRuntimeConfig be used when in serverless mode? The following code:

import getConfig from 'next/config';
const { serverRuntimeConfig } = getConfig();

returns

Cannot destructure property serverRuntimeConfig of 'undefined' or 'null'

For publicRuntimeConfig there is an error saying that it can’t be used but not for that one.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
rnackencommented, Oct 9, 2019

If you are using a custom server, be sure to use getConfig only after initialisation of the Next app:

import getConfig from 'next/config';

console.log(getConfig()) // undefined - no config initialised yet
const app = next({ ... })
console.log(getConfig()) // this works
2reactions
Timercommented, Oct 10, 2019

When deploying to ZEIT Now the target is forced to serverless – you cannot deploy a server Next.js app to ZEIT Now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js Cannot destructure property 'publicRuntimeConfig' of ...
We have this function below which is stored in common folder to be used for both client and server, and it fails when...
Read more >
[next.js] Cannot destructure property 'BACKEND_URL ... - GitLab
publicRuntimeConfig' as it is undefined. I have an app that's written in next.js, that has env variables. App works perfectly locally ( yarn ......
Read more >
Next.js error: Cannot destructure property? : r/learnjavascript
I am following a tutorial and I cannot figure out why Next keeps throwing this error: TypeError: Cannot destructure property 'loginUser' of ...
Read more >
Cannot destructure property 'styles' of 'this.context' as it is null
Learn how to fix Next.js error: TypeError: Cannot destructure property 'styles' of 'this.context' as it is null.
Read more >
next.config.js: Runtime Configuration
Place any server-only runtime config under serverRuntimeConfig . Anything accessible to both client and server-side code should be under publicRuntimeConfig . A ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found