Skip to content
Docs

Overview

Runtimes and module formats

ESM packages with a separate build for Node.js, browsers, and React Native.

Overview

All four packages are ESM-only TypeScript packages and require Node.js 20 or later when run on Node.js. The client API is the same on every platform; only setup and the keystore backend differ. Step-by-step setup for each platform is in Platforms.

Platform builds

@gray3/client and @gray3/keystore publish one build per platform through package exports conditions. Bundlers choose the right one automatically:

  • react-native: Metro (Expo SDK 53+ and React Native 0.79+ by default; enable unstable_enablePackageExports on older versions)
  • browser and worker: Vite, webpack 5, Next.js client bundles, esbuild with --platform=browser
  • node: Node.js, Next.js server bundles, and other server runtimes

Each build includes only the code its platform can run. For example, the browser build of @gray3/keystore has no file-based SQLite, and asking for it throws unsupported_capability.

TypeScript

Use "moduleResolution": "bundler" (apps built with a bundler) or "node16" / "nodenext" (Node.js) so TypeScript reads the exports map. Import from the package roots and from the keystore subpaths @gray3/keystore/node, @gray3/keystore/expo, and @gray3/keystore/web only on their matching platform.

@gray3/cloud

@gray3/cloud is server-side only. It runs on Node.js 20+, Deno, Bun, and edge runtimes, and throws if constructed in a browser, extension, or React Native app. See Install and initialize.

WebAssembly

Polkadot and Bittensor crypto uses inlined WebAssembly in browsers and an asm.js build on React Native. The SQLite web keystore loads sql-wasm.wasm from a URL you serve. Monero wallet sync loads WebAssembly on demand; call close() on the Monero wallet after sync or send to release it.