I’ve made a library for that! https://codeberg.org/prettyid
Of course, if you like the idea but don’t want to add another dependency, you can copy-paste the three-liner as it is! (And I’m sure it’s not even copyrightable right now :-)
Also requires two other packages to run its 3 lines of code.
"dependencies": { "@scure/base": "^1.1.7", "uuidv7": "^1.0.1" }
E.g.: user_2x4y6z8a0b1c2d3e4f5g6h7j8k