SamplePack
SamplePack12mo ago

Generating randomness

Anyone have advice for alternatives to using "crypto" in a convex mutation to generate a randomUUID ?
4 Replies
lee
lee12mo ago
I suggest using crypto
lee
lee12mo ago
specifically crypto.randomUUID() should work https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID
MDN 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.
SamplePack
SamplePackOP12mo ago
I got a warning that I needed to target "Platform:node" in order to use Crypto
lee
lee12mo ago
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.

Did you find this page helpful?