Installing logsnatch with nuxt

createApp I want to installl logsnatch globally. The docs say: import { createApp } from 'vue'; import LogSnag from '@logsnag/vue'; const app = createApp(App); app.use(LogSnag, { token: '<TOKEN>', project: '<PROJECT_NAME>' }); app.mount('#app');. But there arent any createApp on nuxt
5 Replies
kapa.ai
kapa.ai5d ago
Hi @IsaacR943. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In Nuxt (especially Nuxt 3), you do not use createApp directly as you would in a standard Vue application. Instead, you should register plugins or libraries globally using Nuxt's plugin system. To install something like LogSnag globally in Nuxt, you would typically create a plugin file (e.g., plugins/logsnag.client.ts) and use defineNuxtPlugin to register it with your app. Here’s an example pattern based on how other Vue plugins are integrated in Nuxt 3:
// plugins/logsnag.client.ts
import LogSnag from '@logsnag/vue'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(LogSnag, {
token: '<TOKEN>',
project: '<PROJECT_NAME>'
})
})
// plugins/logsnag.client.ts
import LogSnag from '@logsnag/vue'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(LogSnag, {
token: '<TOKEN>',
project: '<PROJECT_NAME>'
})
})
This approach is similar to how other Vue plugins (like PrimeVue's ToastService) are registered in Nuxt 3, as shown in the knowledge sources:
you have to define a nuxt plugin before using "primevue/toastservice" add a plugin plugins/primevue-toastservice.ts first
import ToastService from 'primevue/toastservice'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(ToastService);
});
import ToastService from 'primevue/toastservice'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(ToastService);
});
now you can use it read the nuxt3 plugins document for more details how to integrate toast prive into nuxt3?
So, you do not need to use createApp in Nuxt. Instead, use the plugin system as shown above. Make sure to use the .client.ts suffix if the library is client-side only. If you need more details, refer to the Nuxt 3 plugins documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5d ago
<@1223715160502571129> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
IsaacR943
IsaacR943OP5d ago
and how would i use logsnag in the server?
Cake
Cake5d ago
you don't
IsaacR943
IsaacR943OP5d ago
whooop, already did Just for breaking app errors, not for every single log

Did you find this page helpful?