Search code examples
vue.jsconstantsnuxt.js

What is the best way to store constants in Nuxt?


I have a nuxt project (vuejs) and I'm wondering how to store constants in my project ? ( about 50 constants).

Thank you for your response. kaboume


Solution

  • You can create a constants.js file:

    // constants.js
    export const CONSTANT_1 = 'CONSTANT_1';
    export const CONSTANT_2 = 'CONSTANT_2';
    export const CONSTANT_3 = 'CONSTANT_3';
         
    // And call it like this
    import { CONSTANT_1 } from 'constants';