DEV Community

Jeon
Jeon

Posted on • Edited on

UUID libraries for React Native

1. react-native-uuid

⚠️ Caution
react-native-uuid appears to support up to v5 at the time of writing.

npm install react-native-uuid
Enter fullscreen mode Exit fullscreen mode
import uuid from 'react-native-uuid';
uuid.v4();
Enter fullscreen mode Exit fullscreen mode

2. uuid (and plus)

npm install uuid react-native-get-random-values
npx pod-install
Enter fullscreen mode Exit fullscreen mode
import 'react-native-get-random-values'; // This must precede `uuid`
import { v4 as uuidv4 } from 'uuid';
uuidv4();
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
metal3d profile image
Patrice Ferlet

I really don't understand why not using the browser built-in crypto.randomUUID()

Collapse
 
somidad profile image
Jeon • Edited

That is v4 only. But your comment is also good if v4 is enough.

Collapse
 
metal3d profile image
Patrice Ferlet

Yes :) but your article is for v4 too

Thread Thread
 
somidad profile image
Jeon

Yeah. The examples might be too simple. Both libs support other versions as well as v4.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more