React Native

The React Native environment has a lot of little quirks, so this documentation is aimed at helping smooth those over.

Please feel free to create issues on GitHub for recommendations and additions to this document.


There are several pieces of functionality missing from the current version of React-Native. Here is a list of functionality the ethers/dist/shims will provide if unavailable:

  • ArrayBuffer.isView
  • atob and btoa
  • nextTick
  • Promise
  • String.prototype.normalize
Importing into React-Native
// Import the required shims
import 'ethers/dist/shims.js';

// Import the ethers library
import { ethers } from 'ethers';
This file must be minified, since the React-Native require seems to hijack the variable name require, even when encapsulated inside a closure. The minification process replaces the require with a mangled name, so that there is no collision. This is hacky and in the future a better method would be preferred. Suggestions?
As we find additional features not generally available, they will be added to this shim file. It is targetted toward platforms where build-size is not critical, so functionality is favored over keeping the size small.

TODO: Include instructions on installing crypto performance

  • scrypt (it is VERY slow in React Native; too slow to be functional)