Use nanoid instead of uuid

This commit is contained in:
Linus Flood
2024-12-05 10:57:45 +01:00
parent 66ee5e7cbc
commit bbadd3ac10
3 changed files with 44 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
import { nanoid } from "nanoid"
import { useMemo } from "react"
import { v4 as uuidv4 } from "uuid"
const storageKey = "sessionId"
@@ -12,7 +12,7 @@ export function useSessionId(): string | null {
let currentSessionId = sessionStorage.getItem(storageKey)
if (!currentSessionId) {
currentSessionId = uuidv4()
currentSessionId = nanoid()
sessionStorage.setItem(storageKey, currentSessionId)
}
return currentSessionId

59
package-lock.json generated
View File

@@ -44,6 +44,7 @@
"immer": "10.1.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"libphonenumber-js": "^1.10.60",
"nanoid": "^5.0.9",
"next": "^14.2.18",
"next-auth": "^5.0.0-beta.19",
"react": "^18",
@@ -57,7 +58,6 @@
"sonner": "^1.7.0",
"superjson": "^2.2.1",
"usehooks-ts": "3.1.0",
"uuid": "^11.0.3",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},
@@ -15654,9 +15654,9 @@
}
},
"node_modules/nanoid": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.9.tgz",
"integrity": "sha512-Aooyr6MXU6HpvvWXKoVoXwKMs/KyVakWwg7xQfv5/S/RIgJMy0Ifa45H9qqYy7pTCszrHzP21Uk4PZq2HpEM8Q==",
"funding": [
{
"type": "github",
@@ -15664,10 +15664,10 @@
}
],
"bin": {
"nanoid": "bin/nanoid.cjs"
"nanoid": "bin/nanoid.js"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
"node": "^18 || >=20"
}
},
"node_modules/natural-compare": {
@@ -16747,6 +16747,23 @@
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
"dev": true
},
"node_modules/postcss/node_modules/nanoid": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/preact": {
"version": "10.11.3",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.11.3.tgz",
@@ -19426,6 +19443,24 @@
"node": ">=6"
}
},
"node_modules/typescript-plugin-css-modules/node_modules/nanoid": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/typescript-plugin-css-modules/node_modules/postcss": {
"version": "8.4.38",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
@@ -19774,18 +19809,6 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"dev": true
},
"node_modules/uuid": {
"version": "11.0.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz",
"integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"bin": {
"uuid": "dist/esm/bin/uuid"
}
},
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",

View File

@@ -59,6 +59,7 @@
"immer": "10.1.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"libphonenumber-js": "^1.10.60",
"nanoid": "^5.0.9",
"next": "^14.2.18",
"next-auth": "^5.0.0-beta.19",
"react": "^18",
@@ -72,7 +73,6 @@
"sonner": "^1.7.0",
"superjson": "^2.2.1",
"usehooks-ts": "3.1.0",
"uuid": "^11.0.3",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},