Nuxt environment variables load array of objects
I have a runtimeConfig which includes a list of my projects. They are accessible via NUXT_PUBLIC_PROJECTS env variable. Is it possible to load them directly as an object, or do I have to create a composable useProjects() which returns the projects if they are an array, or parses them via JSON.parse if it is a string?
2 Replies
You can import a json file in your nuxt.config and make the content available via runtimeConfig:
and then use it like:
You can use a json file as @Single has stated. However, you don’t need to pass the data to the runtime config. You can simply import it in whichever page or component you wish to access it from