Forem

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 Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay