0
You can make a plugin and have it hooked into an event and then setup everything. More on which hooks are available
// plugins/setup.ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:created', () => {
Log.info('App created');
});
nuxtApp.hook('app:mounted', () => {
Log.info('App mounted');
});
});
An alternative is that you write everything in the layouts/default.vue
to set everything up in an onMounted
hook, but I find this a bit hacky as you ideally want to separate UI from business logic
Source:stackexchange.com