npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@morojs/client

v0.1.0

Published

The MoroJS client SDK — browser-first and zero-dependency. Ships a socket.io-client-compatible realtime client for the native engine; typed HTTP and shared types are on the roadmap.

Readme

@morojs/client

The MoroJS client SDK — the browser-first, zero-dependency way for any frontend to talk to a MoroJS backend. This release ships the realtime module: a socket.io-client-compatible API over the native engine's WebSocket protocol. Typed HTTP and shared types are next — see the Roadmap.

The MoroJS engine terminates WebSockets natively in C++ (no Engine.IO framing, no long-polling) and routes the upgrade URL path to the matching app.websocket('/path', …) namespace. This package gives the browser a familiar io() / socket.on() / socket.emit() API over that protocol — so migrating an app off socket.io-client is (usually) just changing an import.

Install

npm install @morojs/client

Quick start

import { io } from '@morojs/client';

const socket = io('wss://api.example.com/command-center', {
  query: { orgId: '42' }, // → handshake query (server reads socket.handshake.query.orgId)
});

socket.on('connect', () => socket.emit('subscribe'));
socket.on('event', (payload) => console.log(payload));
socket.on('disconnect', () => console.log('offline'));

Cookies are sent automatically on the upgrade (same-site), so cookie-based auth works with no extra config. query, auth, and extraHeaders are folded into the URL query string (browsers can't set headers on a WebSocket), so the server can read them from the handshake.

Migrating from socket.io-client

For the common case, change only the import:

- import { io, type Socket } from 'socket.io-client';
+ import { io, type Socket } from '@morojs/client';

Supported: io(url, opts), .on/.off/.once/.emit, .connected, .id, .disconnect()/.close(), .io.on('reconnect', …), and the connect / disconnect / connect_error lifecycle events. Reconnection (exponential backoff + jitter) is built in.

Not supported (by design — the engine protocol doesn't have them): HTTP long-polling fallback, multiplexed namespaces over one connection (each path is its own WebSocket), and acknowledgement callbacks.

Typed events

Pass server→client and client→server event maps for end-to-end type safety:

interface ServerEvents {
  ready: (data: { orgId: string; userId: number }) => void;
  event: (data: { type: string; payload: unknown }) => void;
}
interface ClientEvents {
  subscribe: (data?: void) => void;
}

const socket = io<ServerEvents, ClientEvents>('wss://api.example.com/command-center');

socket.on('ready', (data) => data.orgId); // data is typed
socket.emit('subscribe');                  // event name + payload checked

React

@morojs/client/react provides hooks (React is an optional peer dependency):

import { useSocket, useSocketEvent } from '@morojs/client/react';

function CommandCenter({ orgId }: { orgId: string }) {
  const { socket, connected } = useSocket('wss://api.example.com/command-center', {
    query: { orgId },
  });

  useSocketEvent(socket, 'event', (payload) => {
    // handle a live event; auto-unsubscribes on unmount / socket change
  });

  return <span>{connected ? 'live' : 'connecting…'}</span>;
}

The wire protocol

Every frame is a UTF-8 JSON envelope:

{ "event": "subscribe", "data": { "…": "…" } }

socket.emit('event', data) sends { event, data }; an inbound { event, data } is dispatched to the matching .on('event', …) handlers with data as the first argument. That's the whole protocol.

Roadmap

@morojs/client is the umbrella SDK for talking to a MoroJS backend — realtime is the first module.

  • ✅ Realtime — io() / MoroSocket, typed events, /react hooks
  • 🔜 Typed HTTP client — createClient({ baseUrl }) over Moro's route convention, with credentials and normalized validation errors (@morojs/client/http)
  • 🔜 Shared types — the MoroEnvelope wire type ships today; response, error, and pagination envelopes follow with the HTTP module
  • ⬜ Auth / session helpers and additional React hooks

The surface is intentionally 0.x while these land.

License

MIT © Moro Framework Team