Vercel KMS Quickstart
Sign a JWT from a Vercel Function with a Vercel-managed key, then verify it against the issuer's published JWKS. This takes four steps and no private key material in your deployment.
- A Vercel project deployed as, or containing, a Vercel Function.
- The
@vercel/kmspackage installed in your project.
In the Vercel dashboard, open your team's Key Management settings and create an issuer. KMS generates a signing key for the issuer using the default
RS512algorithm.Copy the issuer's ID. You reference it whenever you sign, and it forms the public issuer URL at
https://kms.vercel.com/<issuerId>.Install
@vercel/kmsin your project:pnpm i @vercel/kmsCall
signTokeninside a route handler. Inside a Vercel Function, the deployment's OIDC token authorizes the request automatically, so you pass no credentials:app/api/sign/route.tsimport { signToken } from '@vercel/kms'; export async function GET() { const token = await signToken({ issuerId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', claims: { sub: 'user_123', scope: 'read:data' }, ttl: 300, // seconds }); return Response.json({ token }); }KMS sets the
iat,nbf, andexpclaims, andttldefaults to 300 seconds.A relying party verifies the token against the issuer's JWKS. This example uses
jose:verify.tsimport { createRemoteJWKSet, jwtVerify } from 'jose'; const issuer = 'https://kms.vercel.com/f47ac10b-58cc-4372-a567-0e02b2c3d479'; const jwks = createRemoteJWKSet(new URL(`${issuer}/jwks.json`)); const { payload } = await jwtVerify(token, jwks, { issuer });
- SDK Reference: sign messages, set the region, or call the signing API directly.
- Authentication: how signing and management requests are authorized.
- Key rotation: rotate signing keys without breaking verification.
Was this helpful?