v4 or v7?
v4 is 122 random bits: the usual choice, and what most libraries make. v7 starts with the time in milliseconds, then random bits, so IDs sort by when they were made. Databases index v7 faster because new rows land at the end instead of all over the index.
Both come from your browser's secure random source, and collisions are not a practical concern: you'd need billions of IDs a second for decades to expect one.