title: How to generate UUIDs in JS or React?
body: <p>In my <code>React</code> app, I want to do optimistic updates to create a responsive experience for my users.</p>
  
  <p>Having said that I want to send a user entry to my backend with an ID that will be used so that there won't be a different Id for the user's entry next time he/she uses the app. For example, if the user enters a comment, I want to assign its ID with a real <code>UUID</code> and then send it to my API.</p>
  
  <p>I understand <code>JavaScript</code> or <code>React</code> don't really have a built-in way to generate <code>UUID</code>/<code>GUID</code> values. I've seen many articles that produce randomized values that look like <code>UUID</code>/<code>GUID</code>'s but they really are not and I don't want to use them as ID's for user entries.</p>
  
  <p>How do I get real <code>UUID</code>/<code>GUID</code> values in my frontend? Do I call my backend API to get them? I can create an endpoint in my API that spits out 10 or 20 <code>GUID</code>'s at a time and I can store them for future use in my frontend but this sounds a bit absurd.</p>
  
  <p>I don't want to reinvent the wheel here as I'm not the first person to face this scenario. How do I get real <code>UUID</code> values on my frontend?</p>