# 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](/docs/compute) provides project variables with production, preview and branch scopes; [Prisma Postgres](/docs/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 Schmidt](https://github.com/sorenbs) · 2026-10-19 · 7 min read · Updated 2026-11-10 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. | Value | Appropriate location | What to check | | --- | --- | --- | | Database URL or private API key | Server-side deployment secret configuration. | Only the intended server code receives it; previews use test credentials. | | A public analytics or application identifier | Public configuration when the vendor intends it to be public. | Authorization must not depend on hiding it. | | A build-time credential | The build environment that needs it. | Build scripts and generated output must not print or expose it. | | Local development credential | A 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](https://nextjs.org/docs/app/guides/environment-variables) 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. | Host | Configuration workflow | Decision to make | | --- | --- | --- | | Netlify | [Environment variables](https://docs.netlify.com/build/environment-variables/overview/) can have values by deploy context. | Ensure functions receive required credentials; scope controls depend on the plan. | | Prisma Compute | [Project variables](/docs/compute/environment-variables) support production, preview and individual preview-branch overrides. | Bind server inputs, retain a secure source copy and redeploy after changes. | | Vercel | [Project environment variables](https://vercel.com/docs/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](/docs/composer/databases) 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](/docs/composer/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](/docs/compute/getting-started). The examples use the current `prisma@latest` CLI, which is a [Prisma 8 release candidate](/docs/orm/release-status), 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: ```sh 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: ```sh 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](/docs/cli/project) 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 CLI 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](/docs/prisma-compute/deploy). 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. In a Prisma workspace, the member's role decides who can reach these values. Admins and Developers can manage application environment variables, including secret values, in the projects they can access; Viewers and Billing members cannot see them. These member roles are separate from the `--role production` and `--role preview` flags above, which only select a variable scope. Removing a member or changing their role does not revoke database connection strings, bucket access keys or workspace service tokens they may have copied. For each one that person could reach, create a replacement, update the app and every other consumer such as CI, verify them, then delete the old credential. A Prisma Postgres session that was open before the delete may keep running, so contact Prisma support if one could still be open. Removing a member does not revoke external API keys either: a Developer could view a value such as `MODEL_API_KEY` in the Console. Issue a new key with that vendor and update every consumer, including other deployments and CI. Redeploy where needed and verify each consumer before revoking the old key. The [workspace access guide](/docs/console/workspace-access) lists each role's permissions (checked November 10, 2026). One exception: if the database was created through the Vercel Marketplace, Vercel manages its first credential and stores it in the Vercel project's environment variables. Rotate that one from Vercel, following the [Vercel rotation steps](/docs/guides/postgres/vercel#rotating-your-prisma-integration-secrets-in-vercel), instead of the replacement steps above, then redeploy and verify the apps that use it. ## 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 the CLI never returns their values, so they do not give you a way to pull the stored value into a laptop or refresh 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](/compute/ai-business-api-tool-calls) covers argument validation, user permissions and ambiguous results after an upstream timeout. ## Frequently asked questions ### Is an .env file on my laptop enough for deployment? 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. ### Can I use NEXT_PUBLIC_DATABASE_URL in Next.js? 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. ### Can I download stored Prisma Compute secrets later? Not with the CLI: it lists names and metadata, never stored values, and has no command to pull them into a local file. In the Console, workspace Admins and Developers with access to the project can view a value. Keep a secure source copy in a secret manager, then update the platform value and redeploy when rotating a credential. ### Does a preview variable automatically mean a separate database? 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. [Read Compute variable configuration](/docs/compute/environment-variables) ## Related guides - [A test app with a separate database](/postgres/typescript-test-environment) - [Deployment acceptance and handoff](/compute/deployment-handoff-checks) - [Connect an existing pg app](/postgres/node-postgres-hosting) - [API key missing after deployment](/compute/missing-environment-variables-after-deploy)