Skip to content

Commit

Permalink
Add UUID v7 to /id
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Jun 24, 2024
1 parent 90cd97e commit 6748388
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/routes/id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ import { json } from "@remix-run/cloudflare";
import { useLoaderData } from "@remix-run/react";
import { useId } from "react";
import { ulid } from "ulidx";
import { v7 } from "uuid";

export function loader() {
return json({
uuid: crypto.randomUUID(),
uuidv4: crypto.randomUUID(),
uuidv7: v7(),
cuid: createId(),
ulid: ulid(),
});
}

export default function Component() {
let { uuid, cuid, ulid } = useLoaderData<typeof loader>();
let id = useId();
let { uuidv4, uuidv7, cuid, ulid } = useLoaderData<typeof loader>();

return (
<main className="flex min-h-screen w-full flex-col items-center justify-center gap-6 font-mono">
<Identifier label="UUID" value={uuid} />
<Identifier label="UUID v4" value={uuidv4} />
<Identifier label="UUID v7" value={uuidv7} />
<Identifier label="CUID" value={cuid} />
<Identifier label="ULID" value={ulid} />
</main>
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"tiny-invariant": "^1.3.1",
"turbo-stream": "^2.0.1",
"ulidx": "^2.3.0",
"uuid": "^10.0.0",
"zod": "^3.22.4"
},
"devDependencies": {
Expand All @@ -97,6 +98,7 @@
"@types/prismjs": "^1.26.3",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^10.0.0",
"@vitejs/plugin-react": "^4.0.3",
"@vitest/coverage-v8": "^1.2.1",
"cross-env": "^7.0.3",
Expand Down

0 comments on commit 6748388

Please sign in to comment.