Example import { v1 as uuidv1, v4 as uuidv4 } from 'uuid' import { nanoid } from 'nanoid' const UuidExample = () => ( <> <div>uuidv1(): <strong>{uuidv1()}</strong></div> <div>uuidv4(): <strong>{uuidv4()}</strong></div> <div>nanoid(): <strong>{nanoid()}</strong></div> <div>nanoid(5): <strong>{nanoid(5)}</strong></div> <div>crypto.randomUUID(): <strong>{crypto.randomUUID()}</strong></div> </> ) Math.random() There is a usual need to generate a unique string as a u niversally u nique id entifier (UUID) We may just type some random string from the keyboard Ada78Gfh Or dynamically generate it via Math.random().toString() But a better way to use existing libraries nanoid() nanoid package Install a package with npm i nanoid uuid() uuid package Install a package with npm i uuid crypto.randomUUID() Browsers and node supports a uuid generator now - crypto.randomUUID() crypto.randomUUID() and generates similar string "36b8f84d-df4e-4d49-b662-bcde71a8764f"