Use Cases

Can I use Traverse with React?

Yes. The Traverse browser adapter lets you load and call capabilities inside a React application. The same WASM binary that runs your pricing logic or eligibility rules on the server executes in the browser, with identical contract enforcement and no network round-trip.

Why you would do this

The main use case is consistency. If your checkout flow computes a price in React before the user submits, and your API computes the same price after submission, you want both computations to use the same logic and produce the same result. With Traverse, they run the same binary. There is no risk of a JavaScript implementation drifting from the server-side implementation.

How it works

The traverse-expedition-wasm crate compiles the Traverse runtime to WASM so it can run inside the browser. You load your capability binary as a URL or bundled asset, initialize the runtime, and call capabilities from JavaScript or TypeScript. The React integration guide walks through the setup in detail.

  • Load the capability binary once on component mount
  • Call capabilities on user input events or form submissions
  • The runtime validates the contract before and after execution
  • Results are typed and match your contract's output schema

Current status

The browser adapter is in active development as of v0.7.0. The local target is stable for server-side use. Browser deployment is available but not yet production-ready. See the React integration guide for the current setup and known limitations.

Server-side React (Next.js, Remix)

If you are using a server-side React framework, you can call Traverse capabilities from your server components or API routes using the local target — no browser adapter needed. The capability runs on your Node.js server via the CLI or directly through the runtime crate.