Gathering detailed insights and metrics for vue-simple-websocket
Gathering detailed insights and metrics for vue-simple-websocket
Gathering detailed insights and metrics for vue-simple-websocket
Gathering detailed insights and metrics for vue-simple-websocket
vue3-websocket
Simple package for implementing WebSocket into your Vue 3 application
@wuild/vue-websocket
A simple WebSocket client plugin for Vue2 with automatic reconnect
adonis-vue-websocket
Simple client for communicate VueJS and AdonisJS throught websocket
@morphosis/vue-websocket
simple websocket connector
A simple native reconnecting websocket plugin for Vue.js
npm install vue-simple-websocket
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
9 Stars
20 Commits
6 Forks
1 Watchers
8 Branches
1 Contributors
Updated on Oct 08, 2024
Latest Version
1.0.0
Package Id
vue-simple-websocket@1.0.0
Unpacked Size
21.29 kB
Size
6.20 kB
File Count
16
NPM Version
7.3.0
Node Version
15.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A simple native reconnecting websocket client for Vue.js.
If you like or use this project, please consider supporting my work. Thanks! 🙏🏼
These instructions are for usage with Vue 3.x.
For usage information with Vue 2.x, see here. The older version will not receive updates.
npm install vue-simple-websocket --save
In the Vue app entry file main.js
1import VueSimpleWebsocket from "vue-simple-websocket"; 2 3const app = createApp(App); 4// Configure the server to connect to and reconnection parameters 5// Here, we enable reconnection and retry every 5s if connection is lost 6app.use(VueSimpleWebsocket, "wss://echo.websocket.org", { 7 reconnectEnabled: true, 8 reconnectInterval: 5000 9}); 10app.mount("#app");
The plugin adds a $socketClient
to your app.
In your components, you can handle websocket events by setting them up in the created
or mounted
hook.
onOpen
— event when socket is connectedonMessage
— event when socket receives a messageonClose
— event when socket is closedonError
— event when socket is closed abnormallyIf the connection is broken, the event handlers will continue to work when reconnection succeeds.
1// Component.vue 2export default { 3 name: 'Component', 4 // 5 created () { 6 this.$socketClient.onOpen = () => { 7 console.log('socket connected') 8 } 9 this.$socketClient.onMessage = msg => { 10 console.log(JSON.parse(msg.data)) 11 } 12 this.$socketClient.onClose = () => { 13 console.log('socket closed') 14 } 15 this.$socketClient.onError = () => { 16 console.log('socket error') 17 } 18 } 19}
send()
This calls the websocket send
method and can be used for sending string data.
1let data = { 2 type: 'message', 3 text: 'hello there' 4} 5this.$socketClient.send(JSON.stringify(data))
sendObj()
A convenience method sendObj
is available for sending javascript objects:
1let data = { 2 type: 'message', 3 text: 'hello there' 4} 5this.$socketClient.sendObj(data)
This package is under development, and I'm still learning how maintaining and and publishing npm packages work. If you have more experience in building and maintaining javascript modules, I'd love to hear from you.
This is based on a simple websocket plugin that I wrote for my projects, which I am now releasing as a Vue.js plugin.
This is also a personal project to learn how to build and publish packages on npm. I have deliberately started with a repository from the ground up (instead of going with a template starter) in order to get my hands dirty setting up various components such as babel
, rollup
as well as tests using jest
. As you can probably tell, there is a fair bit of work that needs to be done in order to make this package robust and maintainable.
I'd be super grateful to get pointers from folks who have more experience building and maintaining packages on npm. :)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
34 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
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 More