Installation
Install drizzle-secrets and generate an encryption key.
Install the package
npm install drizzle-secretsdrizzle-orm (>=1.0.0-rc.3) is a peer dependency. The package uses
node:crypto, so it runs on Node.js, Bun, and Deno, and on any edge runtime
with Node.js compatibility enabled.
Generate a key
Keys are 32 random bytes (256 bits), base64-encoded. Generate one with the CLI:
npx drizzle-secrets generate-keyStore it like any other secret, for example in .env:
ENCRYPTION_KEY="q0b3...base64...="Losing the key means losing the data: there is no way to recover a value
without the key that encrypted it. Back keys up in your secret manager, and
never commit them.
Next steps
- Basic usage: declare secret columns and read them back.
- Key rotation: set things up so you can change keys later.