0.0.2 • Published 3 years ago

@kontikijs/vite-plugin-socket.io v0.0.2

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

License Contributors Forks Stargazers Issues

Note

Under development

Like this project?

A ⭐ will go a long way 🙏

About

This plugin makes it easier to setup socket.io v4 for your project as it takes care of the server API & Client API. It will try to figure out what JS framework you're using and then inject a client script configured to be compatible with your JS framework, through Vite's transformIndexHtml hook.

Features

Usage

npm i vite-plugin-socket-io -D # yarn add vite-plugin-socket-io -D

Add it to vite.config.js

// vite.config.js (commonjs)
import { socketIO } from 'vite-plugin-socket-io'

export default {
  plugins: [
    socketIO(/** options */) // Setup completed!
  ]
}

Server API

The options parameter accepts any option listed in Socket.io v4 docs

/** Example */
socketIO(server, {
  pingInterval: 10000,
  pingTimeout: 5000,
  cookie: false
})

If no server object is passed through the param, it will use the server object from Vite's configureServer hook.

Client API (Vue)

/** Example */

Client API (React)

/** Example */

Client API (Svelte)

/** Example */

Contributors

GitHub Contributors Image

License

MIT License © 2021 Tikken

0.0.2

3 years ago