Can't get the Vue-sonner package to work...
Nuxt Version: 3.16.2
Vue Sonner Version: 1.3.2
(https://vue-sonner.robertshaw.id)
Hello Nuxt community. I am experiencing issues with the "Vue-sonner" package. I wanted to ask you guys to see if anyone in here has experienced the same and has found the correct solution to this.
I have attached the error as a screenshot and below is the code that I am using to test if it works. Anyone knows what I am doing wrong?
Here is my component code:
Here is my app.vue code:
Can anyone here spot why this wont work?

3 Replies
Hi @Polak. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the code you've shared, I can see a potential issue with how you're implementing the Vue Sonner toast library in your Nuxt 3 application. The problem appears to be related to how Vue plugins need to be registered in Nuxt.
In Nuxt 3, when using third-party Vue plugins like Vue Sonner, you need to create a plugin to properly register them with your Vue application. This is similar to how other toast libraries like PrimeVue's ToastService need to be registered.
Here's what you should do:
1. Create a plugin file for Vue Sonner. Create a file at
plugins/vue-sonner.ts
with the following content:
This registers the Toaster component globally in your Nuxt application.
2. Keep your app.vue
file as is, with the Toaster component:
3. In your component, you should be able to use the toast function as you're doing:
This approach is similar to how other Vue plugins are integrated into Nuxt, as shown in the PrimeVue toast example from the knowledge sources how to integrate toast prive into nuxt3?.
If you're still experiencing issues, you might want to consider using Nuxt UI's built-in toast system, which is designed to work seamlessly with Nuxt. It provides a similar API through the useToast
composable and includes a Toaster component that's already integrated with the framework Components.
Let me know if this helps resolve your issue!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@260534435915628554> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
So I am dumb. Read the docs more carefully and you'll find out that for Nuxt there is some other steps.