DEV Community

Discussion on: Nuxt.js Environment Variables (without dotenv)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
deeja profile image
Daniel Blackwell

If the env is incoming, within the nuxt.config.js you can access it using the process.env.VARIABLENAME

 privateRuntimeConfig: {
       VARIABLENAME: process.env.VARIABLENAME
}
Enter fullscreen mode Exit fullscreen mode

If it's not incoming, then you can set it and use it within the file.

const myVariable = "something"

 privateRuntimeConfig: {
       VARIABLENAME: myVariable
}
Enter fullscreen mode Exit fullscreen mode