In this video, we will set environment variables, serverRuntimeConfig and publicRuntimeConfig.

We also have a look into cross-env and dotenv packages to help us out with environment variables

From Next.js documentation:
Generally, you’ll want to use build-time environment variables to provide your configuration. The reason for this is that runtime configuration (serverRuntimeConfig and publicRuntimeConfig) adds rendering/initialization overhead and is incompatible with Automatic Static Optimization.


Timeline:

  • 00:00 Presentation Starts
  • 01:33 Open VsCode and env variable setup recommendation using cross-env
  • 03:50 build-time environment variables
  • 05:15 use next.config.js
  • 07:55 create a new component with getServerSideProps to use runtime configuration
  • 13:40 warning for some possible security problems when using serverRuntimeConfig
  • 15:20 simple example using dotenv
  • 18:30 Conclusion

Github Repository: https://github.com/bmvantunes/youtube-2020-april-nextjs-part10

#next #react #javascript #web-development #programming

Next.js Tutorial - Environment Variables and Runtime Configuration
11.50 GEEK