Installations
npm install vue-3-socket.io
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.14.0
NPM Version
8.1.0
Score
64.3
Supply Chain
95.5
Quality
73.8
Maintenance
50
Vulnerability
98.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
Download Statistics
Total Downloads
193,376
Last Day
264
Last Week
1,294
Last Month
5,446
Last Year
54,505
GitHub Statistics
MIT License
41 Stars
124 Commits
23 Forks
1 Branches
1 Contributors
Updated on Dec 27, 2024
Bundle Size
98.62 kB
Minified
27.52 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.5
Package Id
vue-3-socket.io@1.0.5
Unpacked Size
149.92 kB
Size
70.15 kB
File Count
8
NPM Version
8.1.0
Node Version
16.14.0
Total Downloads
Cumulative downloads
Total Downloads
193,376
Last Day
42.7%
264
Compared to previous day
Last Week
-5.9%
1,294
Compared to previous week
Last Month
20.3%
5,446
Compared to previous month
Last Year
10.7%
54,505
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Vue-3-Socket.io is a Vue 3 compatibility version of this repo
All thanks to its author
Demo
are you looking for old documentation? it's here
🚀 Installation
1npm install vue-3-socket.io --save
Using Connection String
1import Vue from 'vue' 2import store from './store' 3import App from './App.vue' 4import VueSocketIO from 'vue-3-socket.io' 5 6Vue.use(new VueSocketIO({ 7 debug: true, 8 connection: 'http://metinseylan.com:1992', 9 vuex: { 10 store, 11 actionPrefix: 'SOCKET_', 12 mutationPrefix: 'SOCKET_' 13 }, 14 options: { path: "/my-app/" } //Optional options 15})) 16 17new Vue({ 18 router, 19 store, 20 render: h => h(App) 21}).$mount('#app')
Using socket.io-client Instance
1import Vue from 'vue' 2import store from './store' 3import App from './App.vue' 4import VueSocketIO from 'vue-3-socket.io' 5import SocketIO from 'socket.io-client' 6 7const options = { path: '/my-app/' }; //Options object to pass into SocketIO 8 9Vue.use(new VueSocketIO({ 10 debug: true, 11 connection: SocketIO('http://metinseylan.com:1992', options), //options object is Optional 12 vuex: { 13 store, 14 actionPrefix: "SOCKET_", 15 mutationPrefix: "SOCKET_" 16 } 17 }) 18); 19 20new Vue({ 21 router, 22 store, 23 render: h => h(App) 24}).$mount('#app')
Parameters | Type's | Default | Required | Description |
---|---|---|---|---|
debug | Boolean | false | Optional | Enable logging for debug |
connection | String/Socket.io-client | null | Required | Websocket server url or socket.io-client instance |
vuex.store | Vuex | null | Optional | Vuex store instance |
vuex.actionPrefix | String | null | Optional | Prefix for emitting server side vuex actions |
vuex.mutationPrefix | String | null | Optional | Prefix for emitting server side vuex mutations |
🌈 Component Level Usage
If you want to listen socket events from component side, you need to add `sockets` object in Vue component, and every function will start to listen events, depends on object key
1new Vue({ 2 sockets: { 3 connect: function () { 4 console.log('socket connected') 5 }, 6 customEmit: function (data) { 7 console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)') 8 } 9 }, 10 methods: { 11 clickButton: function (data) { 12 // $socket is socket.io-client instance 13 this.$socket.emit('emit_method', data) 14 } 15 } 16})
Dynamic Listeners
If you need consuming events dynamically in runtime, you can use `subscribe` and `unsubscribe` methods in Vue component
1this.sockets.subscribe('EVENT_NAME', (data) => { 2 this.msg = data.message; 3}); 4 5this.sockets.unsubscribe('EVENT_NAME');
Defining handlers for events with special characters
If you want to handle 'kebab-case', or "event with space inside it" events, then you have to define it via the following way
1export default { 2 name: 'Test', 3 sockets: { 4 connect: function () { 5 console.log('socket to notification channel connected') 6 }, 7 }, 8 9 data () { 10 return { 11 something: [ 12 // ... something here for the data if you need. 13 ] 14 } 15 }, 16 17 mounted () { 18 this.$socket.subscribe("kebab-case", function(data) { 19 console.log("This event was fired by eg. sio.emit('kebab-case')", data) 20 }) 21 } 22}
🏆 Vuex Integration
When you set store parameter in installation, `Vue-Socket.io` will start sending events to Vuex store. If you set both prefix for vuex, you can use `actions` and `mutations` at the same time. But, best way to use is just `actions`
1import Vue from 'vue' 2import Vuex from 'vuex' 3 4Vue.use(Vuex) 5 6export default new Vuex.Store({ 7 state: {}, 8 mutations: { 9 "<MUTATION_PREFIX><EVENT_NAME>"() { 10 // do something 11 } 12 }, 13 actions: { 14 "<ACTION_PREFIX><EVENT_NAME>"() { 15 // do something 16 } 17 } 18})

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 3/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-03-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to vue-3-socket.io
vue-3-ts-socket.io
socket.io implementation for Vue.js version 3 and Vuex with Typescript
vue-3-socket.io-ext
socket.io implementation for Vue.js and Vuex
@kim5257/vue-socket.io-pinia
This template should help get you started developing with Vue 3 in Vite.
vue-connexion
A package providing Socket.io bindings for Vue 3 with Composition API.