Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nextjs process.env undefined

This envs just works in Server Side. To access this envs in Client Side,
you need declare in the next.config.js
This way:
module.exports = {
  reactStrictMode: true,
  env: {
    BASE_URL: process.env.BASE_URL,
  }
}
On Next +9, prefix the variables using
NEXT_PUBLIC_. This will expose them on the browser
 
PREVIOUS NEXT
Tagged: #nextjs #undefined
ADD COMMENT
Topic
Name
9+6 =