Builder's DayFree, on demandWatch the talks

Where do database passwords and API keys go when I deploy a TypeScript app?

Put database passwords and private API keys in the app host's server-side secret configuration, scoped separately for production and previews. Prisma Compute provides project variables with production, preview and branch scopes; Prisma Postgres can be connected through a database dependency or a server-side URL. Vercel and Netlify also provide deployment environment variables. Keep credentials out of Git and browser bundles, and redeploy when the deployed configuration needs to change.
By Søren Bramer Schmidt7 min read

A database URL is a credential, even though it looks like a setting. A model API key or payment secret can also authorize work that costs money or changes records. The browser should call your authenticated application server; that server uses the private credential for the relevant operation.

We make Prisma Compute and Prisma Postgres. The host and framework documentation linked here was checked on October 19, 2026. Prisma ORM is optional.

Which configuration belongs where?

Separate public settings from private credentials and identify when each value is read.

ValueAppropriate locationWhat to check
Database URL or private API keyServer-side deployment secret configuration.Only the intended server code receives it; previews use test credentials.
A public analytics or application identifierPublic configuration when the vendor intends it to be public.Authorization must not depend on hiding it.
A build-time credentialThe build environment that needs it.Build scripts and generated output must not print or expose it.
Local development credentialA local secret source loaded by the development process.Git ignores the file and the credential reaches development resources.

For Next.js, the environment-variable guide explains how NEXT_PUBLIC_ values referenced by the app are included in browser JavaScript during the build. Changing a public setting after that build does not rewrite an existing bundle. A private variable can still leak if application code returns it in a response or writes it to logs.

What do common app hosts provide?

These hosts are ordered alphabetically. Check the deployment context and the code that consumes each variable.

HostConfiguration workflowDecision to make
NetlifyEnvironment variables can have values by deploy context.Ensure functions receive required credentials; scope controls depend on the plan.
Prisma ComputeProject variables support production, preview and individual preview-branch overrides.Bind server inputs, retain a secure source copy and redeploy after changes.
VercelProject environment variables can target deployment environments.Configure the server and any build that needs a value without making it public.

Prisma Compute is useful when the TypeScript app and Prisma Postgres configuration belong in one project. If the app already runs on Netlify or Vercel, keep its private database URL in that host's server configuration and connect to Prisma Postgres from there.

How do I configure secrets on Prisma Compute?

1. Identify dependencies and external credentials

Follow the Composer database guide for a declared database dependency. A dependency named db gives the server service.load().db.url; it does not need an additional manually copied database URL for the same dependency.

For an existing database URL or an external API key, follow service input: declare a secret field, bind the platform variable with envSecret, and read the validated input in server code. Follow that guide to pass the secret to a database or API client in server code. Keep the value out of serialized responses and browser code.

2. Save values in an explicit scope

Use the supported CLI runtime from the setup guide. The examples use the current prisma@latest CLI, which is a Prisma 8 release candidate, rather than an older project-local binary. This configuration work does not require an ORM upgrade.

For an existing project named customer-portal, authenticate first:

npx prisma@latest auth login
npx prisma@latest auth whoami

Load and export the test database URL and test API key into your trusted shell environment from a secret manager. The child CLI process must receive DATABASE_URL and MODEL_API_KEY; unexported shell variables are insufficient. With those variables exported, pass their names so their values do not appear as command arguments:

npx prisma@latest project env add DATABASE_URL --project customer-portal --role preview
npx prisma@latest project env add MODEL_API_KEY --project customer-portal --role preview
npx prisma@latest project env list --project customer-portal --role preview

The project command reference documents this name-only form. add fails when the key already exists in that scope; use update to replace its value. list returns names and metadata, not stored values. Keep the source values in your own secret manager because the platform does not return them later.

Production needs its own values under --role production. A branch-specific preview override uses --branch instead of --role. Verify which database and API account each value reaches; different variable scopes can still hold the same credential by mistake.

3. Deploy and verify behavior

Build and deploy the prepared Composer app using the deployment guide. Variables resolve for the new deployment; updating one does not change an existing version or trigger a deployment by itself.

Check that the server can perform the intended operation using fictional data. Log a missing-variable name or an application error code when useful, rather than its value. A successful variable-list command proves that the key exists, not that it contains the right credential or that the app reads the intended field.

For an AI assistant, make the test from the server through the chosen model client. For a database, verify a harmless query and the expected test record. Keep the deployed test account and database identity in configuration notes without copying passwords into them.

4. Rotate and complete the handoff

When a credential changes, update the correct platform scope and redeploy. Verify the new deployment, then revoke the old credential according to the vendor's rotation procedure. If exposure is suspected, revoke promptly and follow that vendor's incident guidance rather than treating a normal scheduled rotation as sufficient.

Review local files, CI secret copies, platform access and integration tokens during a contractor handoff. Removing a person from one host does not remove copies or access elsewhere. Retain the credential source and recovery process under business ownership.

When do I need another approach?

If the application requires automatic runtime credential refresh or a particular external secret-manager integration, verify the integration explicitly. Prisma Compute project variables are resolved at deploy time and are write-only, so they do not provide an API for retrieving the stored value into a laptop or refreshing an existing instance in place.

A public API intentionally designed for browser use needs its documented user authorization model. Do not embed a privileged database password to bypass that design, even if the rest of the app is hosted on a managed service.

If an AI assistant can call a business API, secret storage is one part of the design. The server-side tool-call guide covers argument validation, user permissions and ambiguous results after an upstream timeout.

Frequently asked questions

No. A local file configures the process that loads it on your machine. Configure the deployed server separately through the host or deployment workflow. Keep real .env values out of Git and retain a secure source copy for recovery.

No. Database credentials must stay server-side. Next.js can inline NEXT_PUBLIC_ variables into browser JavaScript at build time, so that prefix is for values you intend to expose publicly.

No. Stored project variable values are write-only; the CLI lists names and metadata. Keep a secure source copy in a secret manager, then update the platform value and redeploy when rotating a credential.

No. The value must point to a separate database. A preview that receives a production connection string can still change production records, regardless of its branch name.

Give each environment the credentials it needs

Configure server-side inputs and separate preview and production values before deploying the app on Prisma Compute.