Registry / web-framework / vite-plugin-socket-io

vite-plugin-socket-io

JSON →
library1.0.2jsnpmunverified

A Vite plugin that integrates a Socket.IO server into the Vite dev server, enabling real-time WebSocket communication during development. Version 1.0.2 is the latest stable release, updated infrequently. It wraps socket.io and attaches it to the Vite HTTP server, allowing developers to define server and socket event handlers directly in the Vite config. Differentiators: minimal configuration, automatic WebSocket injection into Vite's HMR pipeline, and support for custom socket event callbacks.

npm install vite-plugin-socket-io
INSTALL
IMPORT
SIG · VITE-PLUGIN-SOCKET
V
vite-plugin-socket-io
web-frameworkjavascriptv1.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import vitePluginSocketIO from 'vite-plugin-socket.io'
✗ const vitePluginSocketIO = require('vite-plugin-socket.io')
The plugin is ESM-only; CommonJS require will fail.
vitePluginSocketIO
✓ import { default as vitePluginSocketIO } from 'vite-plugin-socket.io'
✗ import { vitePluginSocketIO } from 'vite-plugin-socket.io'
Named import is incorrect; the module only has a default export.
type imports
✓ import type { Socket } from 'socket.io'
✗ import { Socket } from 'socket.io' (if value not needed)
TypeScript users often incorrectly value-import when only type is needed.

Basic setup to add Socket.IO server to Vite dev server with no extra events.

// vite.config.js import { defineConfig } from 'vite'; import vitePluginSocketIO from 'vite-plugin-socket.io'; export default defineConfig({ plugins: [vitePluginSocketIO()] });
Debug
Known issues
gotchaThe plugin only works in Vite's dev server, not during build.
fix
Use a separate Socket.IO server for production, or conditionally exclude the plugin.
affects: >=0.0.1
gotchaThe default export is not named; named imports will be undefined.
fix
Use default import syntax: import vitePluginSocketIO from 'vite-plugin-socket.io'
affects: >=0.0.1
deprecatedCJS require() is not supported; the package is ESM-only.
fix
Switch to ES modules or use dynamic import().
affects: >=1.0.0
gotchaSocket.IO must be installed as a peer dependency.
fix
Run: npm install socket.io
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: vitePluginSocketIO is not a function
Using named import instead of default import.
fix
Change to: import vitePluginSocketIO from 'vite-plugin-socket.io'
Error: Cannot find module 'socket.io'
Socket.IO not installed as a dependency.
fix
Run: npm install socket.io
Error: Dynamic require of "vite-plugin-socket.io" is not supported
Using require() instead of import for an ESM-only module.
fix
Change to: import vitePluginSocketIO from 'vite-plugin-socket.io'
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
socket.iorequiredpeer dependency for Socket.IO server functionality
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
vite-plugin-socket-io — npm install vite-plugin-socket-io · libregistry