React Native Quick Crypto
Introduction

Quick Start

Getting started with React Native Quick Crypto

react-native-quick-crypto

Introduction

React Native Quick Crypto (also known as RNQC) is the fastest, next-generation cryptography library for React Native. It is designed to be a drop-in replacement for all other React Native crypto libraries and is inspired by the Node.js crypto module, powered by a high-performance C++ JSI binding that executes directly on the native thread.

Deep Dive

Want to understand the architecture? Read our in-depth guide: What is RNQC?

Terminology

Before we proceed, a few key concepts:

  • JSI (JavaScript Interface): A direct C++ interface to the JS runtime, bypassing the slow React Native Bridge.
  • Native Thread: The thread where C++ code executes. We offload heavy crypto work here to prevent UI freezes.
  • Polyfill: We provide a seamless global crypto object, just like in a browser or Node.js environment.

Architecture At a Glance

RNQC is unique because it uses a Hybrid Object model. It lives on both the Javascript thread and the Native thread simultaneously.


Automatic Installation

Follow these steps to integrate Quick Crypto into your React Native project.

Install the Package

Add the dependency using your preferred package manager.

npm install react-native-quick-crypto react-native-nitro-modules
yarn add react-native-quick-crypto react-native-nitro-modules
pnpm add react-native-quick-crypto react-native-nitro-modules
bun add react-native-quick-crypto react-native-nitro-modules

iOS Setup (Cocoapods)

If you are developing for iOS, navigate to your ios directory and install the pods.

cd ios && pod install

Rebuild the App

Since this library includes native C++ code, you must rebuild your native binary.

npx react-native run-android
npx react-native run-ios

Don't forget: You cannot use this library with Expo Go. You must use a Development Build or straight React Native.

Create your first cryptographic operation

Once installed, usage is straightforward. The API mirrors Node.js exactly.

App.tsx
import React, { useEffect } from 'react';
import QuickCrypto from 'react-native-quick-crypto';

// Polyfill global.crypto for full compatibility
QuickCrypto.install();

export default function App() {
  useEffect(() => {
    // Standard Node.js API (SHA-256)
    const hash = QuickCrypto.createHash('sha256')
      .update('Hello World')
      .digest('hex');
    console.log('SHA-256:', hash);
    
    // High-Performance Random Bytes (Native JSI)
    const randomBuffer = QuickCrypto.randomBytes(16);
    console.log('Random:', randomBuffer.toString('hex'));

    // Next-Gen Algorithms (BLAKE3)
    const b3Hash = QuickCrypto.blake3('Fastest Hash', { dkLen: 32 });
    console.log('BLAKE3:', Buffer.from(b3Hash).toString('hex'));
  }, []);

  return null;
}

Why Polyfill?

React Native does not provide a native crypto implementation or a global Buffer environment.

Calling QuickCrypto.install() injects our high-performance C++ bindings into global.crypto and global.Buffer. This is essential because many popular libraries (like ethers, jsonwebtoken, or viem) rely on these Node.js standard APIs to function correctly.

For Expo Users

Quick Crypto includes a Config Plugin for Expo.

Add the plugin to your app.json or app.config.js:

app.json
{
  "expo": {
    "plugins": [
      ["react-native-quick-crypto", { "sodiumEnabled": true }] // Optional configuration
    ]
  }
}

Then rebuild your development client:

npx expo prebuild
npx expo run:ios

FAQ

Does this work with Expo Go?

No. Expo Go does not support custom native modules. You must use a Custom Development Client (CNG) or npx expo prebuild.

Is it faster than react-native-crypto?

Yes, significantly. We use direct C++ JSI bindings instead of the React Native Bridge, which eliminates serialization overhead.


Learn More

New here? Don't worry, we welcome your questions.

If you find anything confusing or have suggestions, please give your feedback on our GitHub Discussions.

Join the Discussion

On this page