Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Generating UUID in react using crypto api

According to MDM (https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) Most modern Browsers support the javascript native crypto api, which supports the former node-js crypto standard.

According to this article in plain js I may create an uuid via

crypto.randomeUUID()

Is there any way to use this interface in react? Since crypto seems to refere to a completely different object in react.

ps. I am aware of the existence of the UUID package, and know that its a common way to generate UUIDs I am just curious.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I guess you are right, the crypto package in React is a different one. To use the one from NodeJs you can call:

window.crypto

I put it in the if to make sure, it is only rendered in the browser.

if (window !== undefined) {
    console.log('randomUUID', window.crypto.randomUUID());
}

or

import crypto from 'crypto';

console.log('crypto.randomUUID()', crypto.randomBytes(16).toString('hex'));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!