server and client build@nuxtjs/separate-env dependency to your project using yarn or npmTo define environment variables only available on server/client side,
use the env key of your nuxt.config.js and nest the variables
in a server or client object:
{
env: {
server: {
ONLY_SERVER: 'yup',
DIFFERENT_ON_BOTH: 'server'
},
client: {
ONLY_CLIENT: 'okay',
DIFFERENT_ON_BOTH: 'client'
},
normalEnvVariableThatWillBeAvailableEverywhere: 'Hi'
}
}
That's it! You are good to go.
IMPORTANT: Be aware that server-side includes every first render of your application.
Your secret tokens won't be included anywhere **except you use them **
yarn install or npm installnpm run devCopyright (c) Alexander Lichter