Getting Started
Table of contents
Install
Add nuxt-envalid
as dev-dependency to your project via yarn
or npm
:
yarn add --dev nuxt-envalid
npm install --save-dev nuxt-envalid
Nuxt config
Add nuxt-envalid
to the buildModules
section of nuxt.config.js
:
// nuxt.config.js
export default {
buildModules: ['nuxt-envalid'],
};
If you are using a Nuxt version previous than v2.9 you have to install the module as a dependency
(No --dev
or --save-dev
flags) and also use modules
section in nuxt.config.js
instead of buildModules
.
There a pretty much four different ways to provide a configuration for this module. You are free the choose which fits you the most.
Inline config
// nuxt.config.js
export default {
buildModules: [
['nuxt-envalid', { /* module config */ }],
],
};
Top level config
// nuxt.config.js
export default {
buildModules: ['nuxt-envalid'],
envalid: {
/* module config */
},
};
Config function
If you need to use a function to provide the module config you are good to go:
// nuxt.config.js
export default {
buildModules: [
['nuxt-envalid', () => ({ /* module config */ })],
],
/* or at top level */
envalid: () => ({
/* module config */
}),
};
Defining a module configuration inline will overwrite a module configuration defined at top level.