Start with TypeScript
Choose Node.js or React Native, make the first connection, and continue with the shared TypeScript interface.
minip2p has one TypeScript interface on Node.js and React Native. Setup and endpoint ownership differ by runtime. Connections, streams, events, pubsub, discovery, and NAT traversal work the same way after the endpoint starts.
Choose your runtime
Node.js quickstart
Install the package, connect to a peer, and measure a Ping RTT.
React Native quickstart
Create a development build and connect from a component.
Import from the package for your runtime:
import { Minip2p } from "@minip2p/node";
// or
import { Minip2p } from "@minip2p/react-native";
Both 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:
- Pass a complete peer multiaddress to
connectAddr. - Wait for
waitPeerReadybefore opening an application stream. - Use
ping,openStream, pubsub, or another operation. - Close the endpoint when its owner shuts down.
connectAddr resolves when minip2p has a usable direct or relayed path.
waitPeerReady waits for Identify and returns the peer’s supported protocols.
Continue
Endpoint lifecycle
Persist identity and shut down cleanly on each runtime.
Connections and streams
Connect, cancel work, and exchange bytes over custom protocols.
Networking and events
Consume events and enable pubsub, discovery, mDNS, or NAT traversal.
TypeScript reference
Look up configuration, methods, events, streams, and errors.