NuID React Native Client SDK


The @nuid/react-native package brings nuid.zk support to the react-native client interface. The package is identical to the original package with native-specific dependencies managed for you. We will be adding more tools both packages in the future.

The package is written in Clojure and is currently compatible with ClojureScript, JavaScript, and any JVM compatible language. To interact with the SDK on @nuid/react-native you'll want to use the @nuid/zk-react-native npm package.

Please contact us if you have any questions regarding usage. We also encourage you to open an issue or pull request if you have any issues or suggestions.

Installation


For general instructions on getting node polyfills for react-native, checkout parshap/node-libs-react-native on GitHub.

1. First you'll need to install a few dependencies:

  • Install the @nuid/zk-react-native package instead of @nuid/zk. This is a react-native specific version of NuID's zk package (which has an identical JS interface to @nuid/zk).
  • You'll also need react-native-randombytes as a top-level dependency in your app so that react-native will link it correctly.
  • And finally, node-libs-react-native for shimming node dependencies in react-native which is necessary to support zk credential and proof generation.
$ yarn add @nuid/zk-react-native node-libs-react-native react-native-randombytes
# if RN < 0.60
$ react-native link react-native-randombytes
# else RN >= 0.60, instead do
$ cd iOS && pod install

2. Next, modify metro.config.js to add extraNodeModules configuration to wire up node-libs-react-native correctly:

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

3. Import node-libs-react-native/globals before you import @nuid/zk-react-native:

// my-rn-project/index.js
// Add globals here (or anywhere _before_ importing @nuid/zk-react-native)
import 'node-libs-react-native/globals';
import { registerRootComponent } from 'expo';
import App from './src/app';
registerRootComponent(App);

Usage


You can see a complete code example using the React Native Client SDK in our examples repo, or go read our Integrating with NuID guide for an in-depth walkthrough of your first integration.

This package is identical to @nuid/zk, please see the usage info in our Web Client SDK docs.

JavaScript Docs


This package is identical to @nuid/zk, please read the docs on our Web Client SDK.