Create unique values with Web Crypto API

Published on: Saturday, 9.03.2024

When needing to generate a unique random value, for an id for example, we can use the crypto interface.

Can be declared in the browser in the following way:

const uniqueID = crypto.randomUUID();

It returns a randomly generated, 36 character long v4 UUID.