Next.js · Middle · Question 39 of 75

Where should you store a secret API key used in a server component?

Explanation

Variables without the prefix are available only on the server. NEXT_PUBLIC_* variables are inlined into the client bundle and visible to everyone. Hardcoding ends up in the repository. .env*.local files aren't committed, and in production the values are set on the platform.

Further reading

Problem with a question

Next.js · Middle · question 39

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz