Registry / messaging / vue-websocket

vue-websocket

JSON →
library0.2.3jsnpmunverified

A socket.io plugin for Vue.js that adds $socket instance property and socket events option to Vue components. Version 0.2.3 is the latest and only release, published in 2018. This package requires socket.io-client and does NOT support native WebSockets; it is a thin wrapper around socket.io. Notable drawbacks: no active maintenance, no TypeScript support, limited documentation, and it does not work with Vue 3. Alternatives include vue-native-websocket or custom implementation.

npm install vue-websocket
INSTALL
IMPORT
SIG · VUE-WEBSOCKET
V
vue-websocket
messagingjavascriptv0.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import VueWebsocket from 'vue-websocket'
const VueWebsocket = require('vue-websocket')
ESM default import is correct; CJS require works but not recommended.
Vue
Vue.use(VueWebsocket)
new VueWebsocket()
Plugin must be registered via Vue.use(), not instantiated.
$socket
this.$socket.emit(...)
this.socket.emit(...)
Property is $socket (with dollar sign) on component instance.

Shows plugin installation, connection options, listening to events, and emitting messages.

import Vue from 'vue'; import VueWebsocket from 'vue-websocket'; Vue.use(VueWebsocket, 'ws://localhost:3000', { reconnection: true }); new Vue({ el: '#app', socket: { events: { message(msg) { console.log('Received:', msg); } } }, methods: { send() { this.$socket.emit('chat', { text: 'Hello' }); } } });
Debug
Known issues
deprecatedPackage is unmaintained and does not support Vue 3 or native WebSocket.
fix
Use vue-native-websocket or implement custom WebSocket integration.
affects: >=0.0.0
breakingRequired socket.io-client is a peer dependency but not listed in package.json; may cause missing module errors.
fix
Manually install socket.io-client: npm install socket.io-client
affects: >=0.0.0
gotchaEvent listeners use 'events' property inside 'socket' object, not 'listeners' or direct $socket.on
fix
Define events under 'socket: { events: { ... } }' in component options.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'socket.io-client'
Missing peer dependency socket.io-client
fix
Run: npm install socket.io-client
TypeError: Cannot read property '$socket' of undefined
Using this.$socket before plugin registration or inside a non-Vue context
fix
Ensure Vue.use(VueWebsocket) is called before creating any component.
[Vue warn]: Property or method "$socket" is not defined on the instance but referenced during render
Plugin not properly installed or misspelled property name
fix
Double-check import and Vue.use() call; use this.$socket (dollar prefix).
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
socket.io-clientrequiredpeer dependency for socket.io functionality
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
vue-websocket — npm install vue-websocket · libregistry