N
Nuxt2mo ago
Alireza

Example of updating app.config at runtime

Doc says app.config is reactive and can be changed at runtime. The docs does not provide any examples though. https://nuxt.com/docs/guide/directory-structure/app-config I am looking for an example of how to do that and what are the use cases of this feature. For example, if we have a color: "#fff" in the app.config, can it be changed at the runtime after fetching the value from the database after the user login? like color.value = userColor It would be also nice if anyone could point to a GitHub repo that uses this or even how to search GitHub to find such a use case.
Nuxt
app.config.ts · Nuxt Directory Structure
Expose reactive configuration within your application with the App Config file.
1 Reply
Dawit
Dawit2mo ago
Nuxt provides the updateAppConfig utility for this. When you call this method with the new config object you want to update in the app config, it will update only the specific property that has changed and leave other properties untouched. Even though, there isn't much else on its use, it is documented here (https://nuxt.com/docs/api/utils/update-app-config). Hope that helps.
Want results from more Discord servers?
Add your server