DEV Community

Evan Winter
Evan Winter

Posted on • Updated on

TIL – Generate unique IDs with Crypto.randomUUID()

Today I learned that you can generate UUIDs using the Web Cryptography API.

Here’s what it looks like:

let uuid = self.crypto.randomUUID();
console.log(uuid); // “36b8f84d-df4e-4d49-b662-bcde71a8764f”
Enter fullscreen mode Exit fullscreen mode

MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID

Top comments (0)