NuxtN
Nuxtβ€’3y agoβ€’
12 replies
plex

How to handle global notifications?

I'd like to show a notification component whenever an event (like an API response) is triggered on any page. Right now I have to include the component on each page separately because there doesn't seem to be a way to listen to events on the layout itself. I've found several solutions for Nuxt 2 (like $nuxt.$emit => $nuxt.$on) but none of them work with Nuxt 3. I've also tried implementing Mitt (https://github.com/developit/mitt) but Nuxt 3 doesn't like that one either.

Is there maybe some other way how to achieve this?
GitHub
πŸ₯Š Tiny 200 byte functional event emitter / pubsub. - GitHub - developit/mitt: πŸ₯Š Tiny 200 byte functional event emitter / pubsub.
GitHub - developit/mitt: πŸ₯Š Tiny 200 byte functional event emitter /...
Was this page helpful?