Node.js - Generate random IDs

The following example uses the built-in crypto library.

const crypto = require('crypto');

const id = crypto.randomBytes(8).toString("hex");

console.log(id);