1.0.2 • Published 2 years ago

vite-plugin-socket-io v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vite Plugin - socket.io

Description

Plugin to add socket.io to a Vite server

Installation

npm i -D vite-plugin-socket.io

Basic Usage

// vite.config.js

import vitePluginSocketIO from 'vite-plugin-socket.io'
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [vitePluginSocketIO()]
})

Options

serverEvents

Function to run when initializing socket.io connection. Check docs here.

socketEvents

Function to run containing socket.io listener and emitters. Check docs here.

Additional Usage Examples

Add listeners

// vite.config.js

import vitePluginSocketIO from 'vite-plugin-socket.io'
import { defineConfig } from 'vite';

const socketEvents = (io, socket) => {
  console.log('socket.io - connection');
  socket.on('disconnect', () => {
    console.log(`socket.io - socket.id \`${socket.id}\` disconnected`)
  })
  socket.on('signin', () => {
    console.log('socket.io - signin')
  })
}

export default defineConfig({
  plugins: [vitePluginSocketIO({socketEvents})]
})
1.0.2

2 years ago

1.0.1

2 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago