Web Crypto API

The standard Web API for cryptography, such as hashing, HMAC signing and encryption, available in browsers, Node.js and the Edge runtime.

In more detail

It exposes crypto.getRandomValues() and the crypto.subtle object with methods such as sign, verify, digest and encrypt. It is asynchronous and works the same in browsers and server runtimes.

Example

Use crypto.subtle.sign('HMAC', key, data) to sign cookies in Next.js middleware running in the Edge runtime.

Related terms

Taught in

References