Realtime WebSocket Notifications for Vue.js
Add WebSocket channels and real-time notifications to Vue 3 and Nuxt apps. Composable-friendly SDK that pairs naturally with reactive refs, onMounted, and onUnmounted lifecycle hooks.
npm install @apinator/client Adding real-time WebSocket events to a Vue 3 application is clean and idiomatic with Apinator's composable-friendly client SDK. Open a persistent WebSocket connection in onMounted, bind events to reactive refs so templates update automatically, and disconnect in onUnmounted. Works with Vue 3 Composition API, Nuxt 3, and Pinia stores.
Quick Start
How to add WebSocket notifications to Vue 3
Add realtime features to your Vue.js app in a few steps.
Install the client SDK
Add the client SDK to your Vue project. Works with Vue 3 and Nuxt.
Create a client instance
Initialize the client with your app key. Set an auth endpoint for private channels.
Subscribe to a WebSocket channel
Create a composable that opens a persistent WebSocket connection, subscribes to a channel, and exposes reactive data.
Use in a component
Call the composable in your component. Messages are reactive and update the template automatically.
Why Vue.js
Built for Vue.js developers
Composition API Ready
Designed for Vue 3 Composition API. Create reusable composables with onMounted/onUnmounted lifecycle hooks.
Reactive Data
Bind channel events to Vue refs. Template updates automatically when new messages arrive.
Nuxt Compatible
Works with Nuxt 3 out of the box. Use in client-only components or with ClientOnly wrapper.
Auto-Reconnect
Built-in exponential backoff reconnection keeps your Vue app connected through network changes.
How WebSocket channels work with Vue 3 Composition API
Vue 3's Composition API maps naturally to WebSocket subscriptions. The onMounted and onUnmounted lifecycle hooks correspond exactly to opening and closing a WebSocket connection, and Vue's reactive refs automatically propagate incoming events to your templates without any manual DOM manipulation.
The recommended pattern is a useChannel() composable that encapsulates the WebSocket subscription, exposes reactive state, and handles cleanup automatically when the component is destroyed. This makes the WebSocket logic reusable across multiple components while keeping your component scripts clean. Because Apinator maintains a single underlying WebSocket connection shared across all subscriptions, calling useChannel() from many components simultaneously is efficient.
For Nuxt 3, the client SDK should run only in client-side code — either inside onMounted or in a component wrapped with <ClientOnly>. Server-side rendering doesn't support persistent WebSocket connections. Apinator's server SDK handles the publish side from Nuxt's server routes and API handlers.
Full Example
Full Example: Realtime WebSocket Chat with Vue 3 Composable
Complete WebSocket example: a reusable useChannel composable and a chat component that displays real-time messages via reactive refs.
Related Docs
Read the core WebSocket guides
Related Use Cases
Explore realtime use cases
Start building realtime Vue.js apps
Completely free. No credit card. No catch.