vercel/next.js · error · InvariantError

Missing encryption key for Server Actions

Error message

Missing encryption key for Server Actions

What it means

Invariant from getActionEncryptionKey: neither NEXT_SERVER_ACTIONS_ENCRYPTION_KEY nor an encryptionKey in the server actions manifest provided a key, yet Server Actions encryption/decryption was requested. It indicates an incomplete build or missing configuration for encrypted action payloads, not user code misuse.

Source

Thrown at packages/next/src/server/app-render/encryption-utils.ts:79

    },
    key,
    data
  )
}

export async function getActionEncryptionKey() {
  if (__next_loaded_action_key) {
    return __next_loaded_action_key
  }

  const serverActionsManifest = getServerActionsManifest()

  const rawKey =
    process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY ||
    serverActionsManifest.encryptionKey

  if (rawKey === undefined) {
    throw new InvariantError('Missing encryption key for Server Actions')
  }

  __next_loaded_action_key = await crypto.subtle.importKey(
    'raw',
    stringToUint8Array(atob(rawKey)),
    'AES-GCM',
    true,
    ['encrypt', 'decrypt']
  )

  return __next_loaded_action_key
}

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Ensure the server action encryption key is generated at build time; do not strip process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, and rebuild.
Defensive patterns

Strategy: validation

When it happens

Trigger: Server Actions encryption runs without an encryption key.

Common situations: Missing NEXT_SERVER_ACTIONS_ENCRYPTION_KEY or key generation failure when using Server Actions.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/2757833239d25baf. Report an issue: GitHub.