Integration & Guides

Using Direct

The Direct client connects to the network for you and exposes everything as plain JSON-RPC, so your app talks to Direct exactly like it talks to any RPC endpoint. There are no code changes, and it works with any library you already use — viem, ethers, or raw fetch.

There are two clients — the Browser SDK for frontend apps and the CLI client for backends. Both take over your JSON-RPC requests and quietly make them faster and more resilient; the difference comes down to where they run. See Getting started for setup steps.

Browser

The Browser SDK (@direct.dev/sdk) is a drop-in fetch wrapper: install it, call install() once at startup, and it takes over requests to your Direct RPC URLs — and only those — so viem, ethers, and plain fetch keep working unchanged.

The browser can’t open raw peer-to-peer connections, so the SDK spreads your requests across many Direct endpoints around the world, each connecting into the peer-to-peer network. You still get no single point of failure, right from the browser — plus:

  • Sub-millisecond reads from a local cache.
  • Direct Sync— only what changed since your last request.
  • Direct Wire— a compact binary protocol tuned for web3.
  • Automatic failover across healthy paths.
  • Optional quorum data integrity across multiple providers.

Backend

Coming soon. For backends and server-side workloads, the CLI client runs alongside your service and exposes a local JSON-RPC endpoint to point your app at.

It offers everything the SDK does, and because it runs natively — without the browser’s networking limits — it opens hole-punched, direct UDP connections to many nodes across the peer-to-peer network at once. That gives you the highest throughput and performance, with no single point of failure. When performance matters most, use the CLI client.

Local-first syncing

Direct’s clients keep the most commonly requested data in sync locally. When you ask for something that’s already in sync, the client returns it instantly — no network round trip.

To keep that local data trustworthy, Direct constantly revalidates popular requests on its end and efficiently tells the client whether its local copy is still current, sending only what changed. The result: the requests your app makes most often come back instantly, while still reflecting the latest state.

Data integrity

You can enable quorum-based data integrity in the client: the same request goes to several independent providers at once, and their responses are compared before you act on the result. Trusting a single RPC provider has led to real incidents — spoofed data and worse — and because Direct has a whole network of providers, it can guard against that by requiring agreement across many. Turn it on for the requests that need it.