Great question — answering as the UphillTech team:
[Edited 2023-03-05 to reflect latest best-practices for producing RFC4122-compliant UUIDs] crypto.randomUUID() is now standard on all modern browsers and JS runtimes. However, because new browser APIs are restricted to secure contexts , this method is only available to pages served locally ( localhost or 127.0.0.1 ) or over HTTPS. For readers interested in other UUID versions, generating UUIDs on legacy platforms or in non-secure contexts, there is the uuid module . It is well-tested and supported. Failing the above, there is this method (based on the original answer to this question): function uuidv4() { return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c => (+c ^...
Full answer by broofa: https://stackoverflow.stackexchange.com/a/2117523 (CC BY-SA 4.0).
Need it done for your business? UphillTech.