I actually use Math.random().toString(36).substr(2) quite often, when I don't want to name things.
But when I want to ensure no collision, I generally use nanoid or uuid/v4. shortid is nice, but may have more collisions than nanoid, as well as slower to generate. (Actually, I read that some parts of the code between shortid and nanoid are shared.)
I actually use
Math.random().toString(36).substr(2)quite often, when I don't want to name things.But when I want to ensure no collision, I generally use
nanoidoruuid/v4.shortidis nice, but may have more collisions thannanoid, as well as slower to generate. (Actually, I read that some parts of the code betweenshortidandnanoidare shared.)Thanks for the input! Updated post to link nanoid.
Yeah, looks like it's published by the same folks and shortId has a dependency on nanoid.