Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 13, 2022 02:35 am GMT

NextJs UUID

I'm trying this

import { randomUUID } from 'crypto'
var id = randomUUID()

in my NextJs app but I'm getting this error:

index.js?46cb:369 Uncaught TypeError: (0 , crypto_WEBPACK_IMPORTED_MODULE_5.randomUUID) is not a function
at eval (index.js?bee7:8:20)
at Module../pages/index.js (index.js?ts=1649816623582:5680:1)
at Module.options.factory (webpack.js?ts=1649816623582:618:31)
at __webpack_require
_ (webpack.js?ts=1649816623582:37:33)
at fn (webpack.js?ts=1649816623582:287:21)
at eval (?595a:5:16)
at eval (route-loader.js?ea34:235:51)

it seems like the crypto library is available to middleware in NextJs (though it should be available at the browser) but that seems complicated to implement. can anyone suggest how to generate a UUID in NextJs?


Original Link: https://dev.to/ekkis/nextjs-uuid-2i6f

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To