cosette/plugins/socket.client.js

19 lines
368 B
JavaScript
Raw Permalink Normal View History

2022-08-22 16:03:08 +02:00
// Nuxt 3: plugins/socket.client.js
import io from 'socket.io-client'
export default defineNuxtPlugin(() => {
const socket = io('http://localhost:3000')
socket.on("message", (arg) => {
console.log(arg); // "world"
});
return {
provide: {
socket: socket
}
}
})
export const socket = io('http://localhost:3000')