Generating randomness
Anyone have advice for alternatives to using "crypto" in a convex mutation to generate a randomUUID ?
4 Replies
I suggest using crypto
specifically
crypto.randomUUID()
should work https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUIDMDN Web Docs
Crypto: randomUUID() method - Web APIs | MDN
The randomUUID() method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
I got a warning that I needed to target "Platform:node" in order to use Crypto
You don't need to import it. It's a global https://developer.mozilla.org/en-US/docs/Web/API/crypto_property
MDN Web Docs
crypto global property - Web APIs | MDN
The global read-only crypto property returns the Crypto object associated to the global object. This object allows web pages access to certain cryptographic related services.