Running Crypto in Expo App

WYCKX
1 min readMay 7, 2021

In testing the waters with bitcoinjs-lib in Expo to build a seamless UI for blockchain transactions on the Bitcoin mainnet we needed to include node modules in our RN environment.

There are multiple solution to the problem such as browserify and nodeify. However the one that helped us get started quickly was node-libs-expo.

The process is easy.

yarn add node-libs-expo && expo install expo-crypto expo-random

Then create a metro.config.js file in the root of your project and add the following code ….

// metro.config.js
module.exports = {
resolver: {
extraNodeModules: require('node-libs-expo'),
},
};

To load globals for Buffer and process it is now important we import expo-node-libs in our project before anything else …

require('node-libs-expo/globals');
// ...

Now run expo start and you should be able to import bitcoinjs-lib.

Hope this helps for anyone looking to work with the Crypto module and Bitcoin tech in their React Native Expo Apps. For a full readme check out the github: https://github.com/annie-elequin/node-libs-expo.

Thanks to all the engineers making this happen.

The team.

--

--

WYCKX

Redefining ownership in real-estate. Blockchain powered community-driven platform to finance and build property for a new generation of urban residents.