Tech
Stop importing `uuid`. `crypto.randomUUID()` has been native since 2021.
The uuid npm package is one of the most downloaded libraries in the JavaScript ecosystem. The vast majority of those installs exist for one thing: uuid/v4 , which generates a random unique identifier in the standard xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx format. The browser — and Node.js — have been doing this natively since 2021. No package needed.
The native API
const id = crypto . randomUUID ();
// "110e8400-e29b-41d4-a716-446655440000"
That's th...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to