0👍
Hi I use it it my app as a plugin:
Define it in socket.js file like this:
import SocketIO from 'socket.io-client';
import VueSocketIoExtended from 'vue-socket.io-extended';
import Vue from 'vue';
export default ({ store, env }) => {
const socket = SocketIO(env.socketUrl, {
transports: ['websocket'],
reconnection: true,
reconnectionAttempts: Infinity,
autoConnect: true,
});
Vue.use(VueSocketIoExtended, socket, { store });
};
then you can include it in nuxt.config.js as plugin:
plugins: [
{ src: '~/socket.js', mode: 'client' },
],
More info about socket library here:
https://www.npmjs.com/package/vue-socket.io-extended
- [Vuejs]-Nuxt.JS scss doesn't load svg files
- [Vuejs]-Vue js text field value becomes empty when new row is appended
Source:stackexchange.com