javascriptnext.jswebapi

Using Web Crypto API in NextJS, but getting error 'crypto is not defined'


Can I use web crypto api in NextJS?

I tried to use

crypto.subtle.digest('SHA-256', data)

but getting an error

ReferenceError: crypto is not defined

Solution

  • Before using the crypto module, just import it with import crypto from "crypto"

    Here are examples for crypto