DEV Community

Evan Winter
Evan Winter

Posted on • Edited on

2 2

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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay