A WebSocket plugin for Vue 3 with optional Vuex or Pinia integration. Current stable version is 3.1.8. It provides out-of-the-box support for connecting to a WebSocket server, handling events (onopen, onclose, onerror, onmessage, reconnect, reconnect_error), and integrates with Vuex or Pinia for state management. Differentiators include built-in heartbeat mechanism to prevent connection drops, customizable mutation/action names for store integration, and TypeScript support. Released relatively stable with infrequent updates.
npm install vue-native-websocket-vue3No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install and configure the plugin in a Vue 3 app with optional Pinia integration, reconnection and JSON formatting.
Use vue-native-websocket (v2) for Vue 2 projects.
Consider using Pinia with custom action names instead of Vuex mutations.
Provide a valid WebSocket URL.
Set store: store in the plugin options.
See README for type declaration examples.
Use JSON.stringify and send directly.
Use `import VueNativeSock from 'vue-native-websocket-vue3'` instead of require.
Use `app.use(VueNativeSock, url, options)` after `const app = createApp(...)`.
Provide a valid WebSocket URL like 'wss://example.com/ws'.
Pass store: store in the third argument options object.
Ensure store mutations do not rely on globalProperties until app is mounted; use alternative state references.