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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yomo/presence

v2.2.18

Published

Edge Infra for Realtime Web Applications, geo-distributed architecture ⚡️

Downloads

58

Readme

🧬 Introduction

Presencejs is a JavaScript library that enables the creation of real-time web applications with a secure, low-latency, and high-performance geo-distributed architecture.

Key Features:

  • Geo-distributed Architecture: Deploy your real-time backend close to users all over the world for better performance.
  • WebTransport Support: WebTransport is an new API that offers low-latency, bidirectional, client-server messaging.
  • Secure, low-latency, and high-performance: PresenceJS prioritizes security, speed, and performance for a seamless user experience.
  • Real-time and collaborative experience: With PresenceJS, components receive data flow in real time, ensuring fast and reactive UI by offering the flexibility to send either unreliable or reliable data
  • Easy to use: PresenceJS is simple to implement, making it an accessible solution for developers.
  • Free for self-managed hosting: PresenceJS is free to use for self-managed hosting, making it an affordable choice for projects of any size.

🌟 Showcase

These React Serverless Components are built with presencejs:

👯‍♀️ GroupHug

Live collaborator avatars for multiplayer web apps

🥷🏼 Quick Start

1. Add presencejs to your web app

Using npm

$ npm i --save @yomo/presence

Using bun.js

$ bun add @yomo/presence

Using pnpm

$ pnpm i @yomo/presence

Create a Presence instance

import Presence from "@yomo/presence";

// create an instance.
const p = new Presence("https://prsc.yomo.dev", {
  url: process.env.NEXT_PUBLIC_PRESENCE_URL,
  publicKey: process.env.NEXT_PUBLIC_PRESENCE_PUBLIC_KEY,
  id,
  appId: process.env.NEXT_PUBLIC_APP_ID,
  debug: true,
});

p.on("connected", () => {
  console.log("Connected to server: ", p.host);
});

Create Channel

add subscribe to peers online event:

const c = p.joinChannel('group-hug', myState);

c.subscribePeers((peers) => {
    peers.forEach((peer) => {
      console.log(peer + " is online")
    }
});

Broadcast messages to all peers in this channel

const cb = () => {
  const state = document.hidden ? "away" : "online";
  c.broadcast("hidden-state-change", { state });
};
document.addEventListener("visibilitychange", cb);

Subscribe messages from the other peers

const unsubscribe = channel.subscribe(
  "hidden-state-change",
  ({ payload, peerState }) => {
    console.log(`${peerState.id} change visibility to: ${payload}`);
  },
);

2. Start prscd backend service

see prscd

🤹🏻‍♀️ API

Presence

  • joinChannel: return a Channel object

Channel

  • subscribePeers: observe peers online and offline events.
  • broadcast: broadcast events to all other peers.
  • subscribe: observe events indicated
  • leave: leave from a Channel

🏡 Self-managed hosting

Tutorial: Single node on Digital Ocean

Tutorial: Geo-distributed system on AWS

Tutorial: Geo-distributed system on Azure

License

The MIT License.