Sometimes, we want to generate unique ID with Node.js.
In this article, we’ll look at how to generate unique ID with Node.js.
How to generate unique ID with Node.js?
To generate unique ID with Node.js, we can use the uuid
package.
For instance, we run
npm install uuid
Then we use it by writing
const {
v1: uuidv1,
v4: uuidv4,
} = require('uuid');
uuidv1();
uuidv4()
to call uuidv1
to return v1 UUID strings and call uuidv4
to return v4 UUID strings.
Conclusion
To generate unique ID with Node.js, we can use the uuid
package.