react-native-get-random-values

A native polyfill that implements crypto.getRandomValues() for React Native so libraries like uuid work without modification.

Library
npm
v2.0.0
414stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity0
Maintenance20
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
53/100Fair
Architecture65
Code Quality30
Innovation70
Learning Curve45

react-native-get-random-values is a small native module that polyfills the Web Crypto API’s crypto.getRandomValues() method for React Native applications. Many popular npm packages, most notably uuid, assume crypto.getRandomValues is available globally, which it normally is in browsers and Node.js but not in the React Native JavaScript runtime. This library patches that gap by exposing a cryptographically secure random number source through native iOS and Android modules, backed by SecRandomCopyBytes on iOS and Java’s SecureRandom on Android.

The package requires no configuration beyond a single import at the top of the app’s entry file. It is implemented as a TurboModule with a codegen-generated spec, so it integrates directly with React Native’s New Architecture, and it gracefully degrades with an insecure Math.random-based fallback (plus a console warning) when running inside Chrome’s remote debugger, where synchronous native calls are not supported.

What You Get

  • A single-import polyfill that installs global.crypto.getRandomValues for the whole app
  • Native secure random number generation backed by SecRandomCopyBytes on iOS and SecureRandom on Android
  • TurboModule/codegen support for React Native’s New Architecture
  • Automatic deference to Expo SDK 48+‘s built-in ExpoCrypto.getRandomValues when available
  • A safe fallback to Math.random with a console warning when running under Chrome remote debugging

Common Use Cases

  • Generating UUIDs in a React Native app with the uuid package, which requires crypto.getRandomValues
  • Implementing client-side token or nonce generation for authentication flows
  • Polyfilling crypto APIs so libraries built for browsers or Node.js work unmodified in React Native
  • Supporting cryptographic operations in wallet, security, or encryption-focused mobile apps

Under The Hood

Architecture The library is a single-purpose native module with a flat, minimal structure rather than layered internals: index.js patches global.crypto.getRandomValues at import time, delegating byte generation to platform-native code reached through React Native’s TurboModuleRegistry (spec/NativeRNGetRandomValues.ts defines the codegen contract, consumed by ios/RNGetRandomValues.mm via JSI and android/src/main/java/org/linusu/RNGetRandomValuesModule.java via the ReactModule bridge). index.web.js is a no-op override for web builds, relying on React Native’s platform-specific file resolution rather than runtime branching. There is no dependency injection or internal layering; the entire module is a thin bridge between a JS-facing polyfill and two native random-byte generators, so the only thing that could meaningfully break downstream consumers is a change to the global.crypto.getRandomValues contract itself.

Tech Stack The JS layer is plain CommonJS with no build step, distributed as-is via npm. Native integration uses Objective-C++ (RNGetRandomValues.mm) implementing a JSI TurboModule on iOS via SecRandomCopyBytes, and Java (RNGetRandomValuesModule.java, RNGetRandomValuesPackage.java) using BaseReactPackage and SecureRandom on Android. The only runtime dependency is fast-base64-decode, used to move random bytes across the bridge as base64 and decode them directly into the caller’s typed array; react-native itself (>=0.81, i.e. New Architecture) is a peer dependency. Distribution uses a CocoaPods podspec for iOS and a Gradle build.gradle for Android, both wired into React Native’s autolinking.

Code Quality No automated test suite, linter configuration, or CI workflow is present in the repository — the spec/ directory holds only the TurboModule’s TypeScript type contract, not test cases. Naming is consistent and the JS source carries JSDoc type annotations for its two exported functions, giving lightweight type-checking value without a full TypeScript build. Error handling is minimal but explicit (a TypeMismatchError and QuotaExceededError guard the two ways getRandomValues can be misused), and the isRemoteDebuggingInChrome check is a deliberate, if implicit, error-avoidance measure. The absence of any tests for a security-sensitive random-number path is the clearest quality gap.

API Design Developer experience is very strong for such a small package: consumers add a single side-effect import at the top of their entry file and every downstream library that expects the standard Web Crypto API works without further changes, mirroring web semantics exactly. The library actively detects and defers to Expo’s own crypto implementation when present rather than conflicting with it, and it fails safe (with a visible warning) rather than crashing under remote debugging. The tradeoff is minimal documentation: a single README covers install and usage with no separate API reference, changelog, or troubleshooting guide beyond what’s needed for this narrow use case.

Used by 8 apps in this directory

TypeScript
99%
Apache 2.0

Colanode

Knowledge Management · Team Chat · Collaboration

5,097

Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.

View details
47
Repo Health
73
Technical
70
Dependency
Built with
TypeScript99%
Updated 5 months ago
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,494

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript45%
Rust43%
Updated 2 days ago
TypeScript
74%
Apache 2.0

Jitsi Meet

Team Chat · Collaboration · Video Conferencing

29,879

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
96
Repo Health
85
Technical
69
Dependency
Built with
TypeScript74%
JavaScript10%
Updated yesterday
TypeScript
76%
Other

Joplin

Note Taking

56,257

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
61
Dependency
Built with
TypeScript76%
JavaScript14%
Updated yesterday
TypeScript
41%
MIT

MentraOS

Developer Tools · AI Development

2,336

The open source operating system and SDK that lets developers build one app and run it across smart glasses from Even Realities, Vuzix, Mentra Live, and more.

View details
92
Repo Health
77
Technical
66
Dependency
Built with
TypeScript41%
Java24%
Kotlin10%
Updated yesterday
TypeScript
85%
GPL 3.0

Notesnook

Note Taking · File Storage · Security

14,533

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
90
Repo Health
84
Technical
60
Dependency
Built with
TypeScript85%
JavaScript12%
Updated 2 days ago
TypeScript
71%
Apache 2.0

Supabase

Developer Tools · Databases · Search

108,912

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript71%
MDX26%
Updated today
TypeScript
92%
Apache 2.0

superset

AI Code Assistants · AI Development

13,825

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
85
Repo Health
80
Technical
67
Dependency
Built with
TypeScript92%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search