PitchHut logo
Build instant multiplayer web apps without a server.
Pitch

Trystero enables instant peer-to-peer communication between browsers, effortlessly creating multiplayer web applications. With powerful features like automatic matchmaking and support for various connection methods, including BitTorrent and MQTT, developers can focus on building unique experiences without the hassle of server management.

Description

Trystero: Build Instant Multiplayer Web Apps Without Server Infrastructure

Trystero allows browsers to connect and communicate with each other directly, enabling the creation of instant multiplayer web applications without the need for server infrastructure or user accounts. Users can effortlessly connect through multiple protocols including 🌊 BitTorrent, 🐦 Nostr, πŸ“‘ MQTT, ⚑️ Supabase, πŸ”₯ Firebase, πŸͺ IPFS, or a custom self-hosted WebSocket relay, all through a unified API.

Key Features

  • Automatic Peer Matching: Trystero simplifies the process of making peer-to-peer connections, eliminating the need for a matchmaking server.
  • Abstractions Over WebRTC: Enhanced usability with features such as:
    • πŸ‘‚πŸ“£ Rooms for broadcasting data to multiple peers.
    • πŸ”’πŸ“© Automatic Serialization/Deserialization of various data types.
    • πŸŽ₯🏷 Metadata Attachment to binary data and media streams.
    • βœ‚οΈβ³ Automatic Chunking and Throttling for large data transfers.
    • ⏱🀞 Progress Tracking for data transfers combined with promise support.
    • πŸ”πŸ“ Session Data Encryption to ensure privacy and security.
    • 🏭⚑ Support for Server-Side Peering with Node and Bun.
    • βš›οΈπŸͺ React Hooks integration for seamless development.

How It Works

Trystero uses WebRTC for direct peer connections. Traditionally, this would require a signaling server to manage connections. However, Trystero abstracts this complexity and provides diverse options for connecting peers while keeping your application’s data private and directly transmitted between users.

Getting Started

To integrate Trystero into a project, install it via a package manager or CDN:

npm i trystero

Or using CDN:

<script type="module">
  import {joinRoom} from 'https://esm.run/trystero'
</script>

After importing, create a room and join peers with this simple setup:

const config = {appId: 'unique_app_id'};
const room = joinRoom(config, 'room_id');

Event Handling

Trystero allows applications to listen for various events such as peers joining/leaving a room or sending audio/video streams, handling them seamlessly with the provided API:

room.onPeerJoin(peerId => console.log(`${peerId} joined`));
room.onPeerLeave(peerId => console.log(`${peerId} left`));

Advanced Features

With Trystero, functionalities like sending custom actions (e.g., notifications, multimedia), handling binary file transfers, and managing session security are straightforward and efficient. The library also supports various types of media streams for both audio and video, enabling rich communication experiences.

Trystero can also be extended through custom strategies, offering developers flexibility in building unique solutions tailored to specific application needs.

Explore live examples and discover inspirational projects built using Trystero here.

0 comments

No comments yet.

Sign in to be the first to comment.