@quangdao/vue-signalr

SignalR plugin for Vue 3
4,484 21
Install
npm install @quangdao/vue-signalr
Latest Version:1.0.1
Vue:3
License:MIT
Last Updated:Dec 23, 2022
Links: GitHub  ·  npm
Maintainer: quangdao

Vue SignalR Plugin

NPM Install

SignalR plugin for Vue 3.

Quick Start

For more detailed instructions, check out the wiki at https://github.com/quangdaon/vue-signalr/wiki.

Installation

This package is available on npm via:

npm install --save @quangdao/vue-signalr

To install in Vue 3:

import { createApp } from 'vue';
import { VueSignalR } from '@quangdao/vue-signalr';
import App from './App.vue';

createApp(App)
  .use(VueSignalR, { url: 'http://localhost:5000/signalr' })
  .mount('#app');

Usage

This plugin provides a composable function to inject the SignalR service. The service exposes a few methods from the SignalR connection to support your app.

import { inject } from 'vue';
import { useSignalR } from '@quangdao/vue-signalr';

interface MyObject {
  prop: string;
}

// Optional Tokens
// Learn More: https://github.com/quangdaon/vue-signalr/wiki/03.-Usage#tokens
const SendMessage: HubCommandToken<MyObject> = 'SendMessage';
const MessageReceived: HubEventToken<MyObject> = 'MessageReceived';

export default {
  setup() {
    // Inject the service
    const signalr = useSignalR();

    // Listen to the "MessageReceived" event
    signalr.on(MessageReceived, () => doSomething());

    // Send a "SendMessage" payload to the hub
    signalr.send(SendMessage, { prop: 'Hello world!' });

    // Invoke "SendMessage" and wait for a response
    signalr.invoke(SendMessage, { prop: 'Hello world!' })
      .then(() => doSomething())
  }
};

Related Packages

@dreamonkey/vue-signalr

SignalR plugin for Vue 3

84,683 25
@dammers/use-signalr-vue

Fully-typed multi-hub SignalR plugin + composables for Vue.

436 2
@latelier/vue-signalr

Signalr client for vue js

9,997 48
vue-stomp

stomp over websocket in vue

4,161 46
ws-plus

Dead Simple Websockets

17,552 9

Version History

Version Released Vue License
1.0.1 >=3 <4 MIT
1.0.0 >=3 <4 ISC
0.0.11 >=3 <4 ISC
0.0.10 >=3 <4 ISC
0.0.9 ^3.1.2 ISC
Pre-releases (1)
Version Released Vue License
1.1.0-alpha.0 >=3 <4 MIT