Skip to content
minip2p
Esc
↑↓navigate↵open⌘Jpreview
On this page

Start with TypeScript

Choose Node.js, React Native or the browser, make the first connection, and continue with the shared TypeScript interface.

minip2p has one TypeScript interface on Node.js, React Native and the browser. Setup and endpoint ownership differ by runtime. Connections, streams, events, pubsub, discovery, and NAT traversal work the same way after the endpoint starts; the browser runs a subset (it dials over WebTransport and cannot listen).

Choose your runtime

Import from the package for your runtime:

import { Minip2p } from "@minip2p/node";
// or
import { Minip2p } from "@minip2p/react-native";
// or
import { Minip2p } from "@minip2p/web";

The packages expose the same application types and operations.

The shared connection flow

Every endpoint needs a 32-byte Ed25519 secret key. Reuse the same key when the peer needs a stable identity.

To connect:

  1. Pass a complete peer multiaddress to connect.
  2. Open application streams once the path is usable. Call waitPeerReady when you need Identify’s advertised protocols.
  3. Use ping, openStream, pubsub, or another operation.
  4. Close the endpoint when its owner shuts down.

connect resolves when minip2p has a usable direct or relayed path. waitPeerReady waits for Identify and returns the peer’s supported protocols. It is not required before openStream for a protocol you already know the remote speaks.

Continue

Last updated on October 22, 2026

Was this page helpful?