SDK overview
The Typescript SDK allows developers to start building browser-based mixnet applications quickly, by simply importing the SDK modules into their code via NPM as they would any other Typescript library.
Currently developers can use different packages from the Typescript SDK to do the following entirely in the browser:
Nym Smart Contracts | Create a simple query or query and execute methods on the smart contracts that run the Nym Mixnet | @nymproject/contract-clients ESM |
Mixnet Client | Send & receive text and binary traffic over the Nym Mixnet | @nymproject/sdk ESM @nymproject/sdk-full-fat ESM pre-bundled @nymproject/sdk-commonjs CommonJS @nymproject/sdk-full-fat-commonjs CommonJS pre-bundled |
mixFetch | A drop-in replacement for | @nymproject/mix-fetch ESM @nymproject/mix-fetch-full-fat ESM pre-bundled @nymproject/mix-fetch-commonjs CommonJS @nymproject/mix-fetch-full-fat-commonjs CommonJS pre-bundled |
Which package should I use?
All packages come in four different variations:
- ESM: For new projects with current tooling. These packages use the ECMAScript Modules (ESM) system. You may need to configure your bundler to handle the packages WASM and Web Worker components;
- ESM full-fat: These ESM packages are pre-bundled and include inline WebAssembly and web worker code;
- CommonJS: For older projects that still use CommonJS. All WebAssembly (WASM) and Web Workers in the package need to be bundled to work correctly;
- CommonJS full-fat: These packages are already pre-bundled and should work in your project as is;
All *-full-fat
variants have large bundle sizes because they include all WASM and web-workers as inline Base64 strings. If you care about your app's bundle size, then use the ESM variant.
As the Typescript SDK and associated modules are still a work in progress, note that the inline WASM and web worker versions are likely to have issues if the web site / app / extension has a strict CSP (opens in a new tab).