Registry / messaging / yawr
library2.4.1jsnpmunverified

YAWR (Yet Another WebSocket RPC) is a lightweight WebSocket RPC library for Node.js and the browser, version 2.4.1. It provides an RPCServer and RPCClient with a simple async/await API for registering and calling remote functions. Employs semantic versioning with regular releases. Key differentiators: minimal footprint, first-class TypeScript support, and no external runtime dependencies. Ships built-in types and uses ESM exports.

npm install yawr
INSTALL
IMPORT
SIG · YAWR
Y
yawr
messagingjavascriptv2.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

RPCServer
import { RPCServer } from 'yawr'
const RPCServer = require('yawr').RPCServer
Default export is not available; use named import.
RPCClient
import { RPCClient } from 'yawr'
import * as yawr from 'yawr'; const client = new yawr.RPCClient(...)
Named import is preferred; the namespace import works but is verbose.
RPCClient (CommonJS)
const { RPCClient } = require('yawr')
const RPCClient = require('yawr')
CommonJS destructuring required; no default export.

Creates an RPC server on port 8080 with an 'echo' function, then connects a client and calls it.

import { RPCServer, RPCClient } from 'yawr'; async function main() { const server = new RPCServer(8080); server.RegisterFunction('echo', async (ctx, data) => { return data; }); const client = new RPCClient('ws://localhost:8080'); await client.connect(); const response = await client.call('echo', 'hello world'); console.log('Server says:', response); client.disconnect(); } main().catch(console.error);
Debug
Known issues
gotchaFunctions must be async or return a Promise; synchronous functions will not work as expected.
fix
Ensure all registered functions are async or return a Promise.
affects: >=1.0.0
gotchaRPCClient.connect() must be awaited before calling any functions; otherwise, call will throw.
fix
Always await client.connect() before using client.call().
affects: >=1.0.0
gotchaRPCServer constructor accepts port only; host is not configurable (binds to 0.0.0.0).
fix
Use RPCServer(port) and rely on default host. Use a reverse proxy for custom host binding.
affects: >=1.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED ::1:8080
Client is trying to connect before the server is fully initialized.
fix
Ensure server is started and ready before client.connect(). Use server.listen callback or await a small delay.
TypeError: client.call is not a function
Using default import (import yawr from 'yawr') instead of named import.
fix
Use import { RPCClient } from 'yawr' and instantiate with new RPCClient(...).
Upgrade
Version history
2.4.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
packageyawr
yawr — npm install yawr · libregistry