UUID libraries for React Native
Jeon

Jeon @somidad

About: I write lessons learned through trial and error. Hope these are useful to you.

Joined:
May 26, 2023

UUID libraries for React Native

Publish Date: Jan 30
0 4

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

Comments 4 total

  • Patrice Ferlet
    Patrice FerletJan 30, 2025

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

    • Jeon
      JeonFeb 2, 2025

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

      • Patrice Ferlet
        Patrice FerletFeb 10, 2025

        Yes :) but your article is for v4 too

        • Jeon
          JeonFeb 10, 2025

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

Add comment