pikku-ws
$
npx mdskill add pikkujs/pikku/pikku-wsBridge Pikku channels to Node.js WebSocket servers using the ws library.
- Connects Pikku's channel system to external WebSocket servers.
- Integrates with the ws library and Node.js HTTP servers.
- Activates when code uses @piku/ws or discusses WebSocket runtime.
- Returns a PikkuWSServer instance configured with HTTP and channel data.
SKILL.md
.github/skills/pikku-wsView on GitHub ↗
---
name: pikku-ws
description: 'Use when setting up a WebSocket server with the ws library in a Pikku app. Covers the ws runtime adapter for Pikku channels.
TRIGGER when: code uses @pikku/ws, user asks about ws library WebSocket server, or Node.js WebSocket runtime.
DO NOT TRIGGER when: user asks about WebSocket wiring/channels (use pikku-websocket) or uWebSockets (use pikku-deploy-uws).'
---
# Pikku WS (WebSocket Server Runtime)
`@pikku/ws` provides a WebSocket server runtime using the [ws](https://github.com/websockets/ws) library, connecting Pikku's channel system to a Node.js WebSocket server.
## Installation
```bash
yarn add @pikku/ws ws
```
## Usage Patterns
### Basic Setup
```typescript
import { PikkuWSServer } from '@pikku/ws'
const wsServer = new PikkuWSServer({
server: httpServer, // Node.js HTTP server
singletonServices,
createWireServices,
channelStore,
})
await wsServer.init()
```
This runtime bridges the `ws` WebSocket library with Pikku's channel wiring. See `pikku-websocket` for channel wiring details and `pikku-deploy-fastify`/`pikku-deploy-express` for integrating with HTTP servers.