Browser guide

This guide will walk you through how to run 0x Mesh directly in the browser and discuss some of the advantages and drawbacks of doing so.

Background

Mesh is written in Go, but can be compiled to WebAssembly and run directly in the browser. This makes it possible for users to share orders and trade directly with one another without relying on any third-party server or database. This approach comes with a lot of advantages, but also has some drawbacks:

Advantages

  • Increased decentralization

  • Little to no hosting costs

  • Ability to trade experimental/niche assets

Drawbacks

  • Longer warm-up time

  • Increased risk of trade collisions

  • Consumes more end-user resources

Installing

For your convenience, we've published an NPM package called @0x/mesh-browser which includes the WebAssembly bytecode and a lightweight wrapper around it. You install this package in exactly the same way as any other NPM package and using it feels exactly like using a native TypeScript/JavaScript library.

To install the NPM package, simply run:

npm install --save @0x/mesh-browser

Or if you are using yarn:

yarn add @0x/mesh-browser

We recommend using a tool like Webpack to bundle the 0x Mesh package and all your other code into a single JavaScript file.

Documentation

Documentation for the @0x/mesh-browser package is available at 0x-org.gitbook.io/mesh/browser.

Example usage

The examples/browser directory includes a bare-bones example of how to use the @0x/mesh-browser and bundle everything together with Webpack.

Last updated