# How does Draftbit handle API keys, secrets, and environment variables?

> Learn how plain text and sensitive environment variables work in Draftbit, what Draftbit encrypts, and why private keys never belong in app code.

Source: https://draftbit.com/faq/how-does-draftbit-handle-secrets-and-environment-variables/ · Last updated: September 2, 2026

Settings stores environment variables per app for development, staging, and production with plain text or sensitive visibility. Plain text values are bundled into the app and visible to users, so Expo apps require the EXPO_PUBLIC_ prefix on them. Sensitive values are encrypted at rest, masked after saving, and kept out of compiled app code, and anything private still belongs on a server.

Each app's environment variables are in its Settings, under Environment Variables. A variable has a name, a value, a visibility, and the environments it applies to, which can be any mix of development, staging, and production. One name can therefore point at a test backend while you build and at the live one when you publish.

Visibility decides where a value can go. Plain text variables are injected into the app and visible to anyone who inspects the compiled code, so use them only for public configuration such as an API base URL or a Supabase publishable key. Expo apps require the `EXPO_PUBLIC_` prefix on plain text names, and web apps and websites built with Vite or Astro use those frameworks' public prefixes. Sensitive variables stay out of runtime app code and compiled bundles. They are available to build and configuration files and to the agent's sandbox, and the Builder masks them after you save.

On Draftbit's side, stored variable values are encrypted with field-level encryption, as are OAuth tokens, MCP credentials, Supabase keys, and other stored secrets, and traffic is protected with TLS. Draftbit's documentation describes the encryption of stored keys as AES-256. The agent's sandbox receives the development values so it can run tooling that depends on them, and the agent can add or update variables when you ask. If a REST connector header reads a sensitive variable, Draftbit refuses to generate frontend client code for it instead of shipping the value.

A database administrator key, payment secret, or AI provider key still needs a trusted server. Call it from a Supabase edge function or your own backend and return only the data the user should see. If a key was ever committed or shipped in a build, rotate it. Removing it from the current file does not remove it from history or from installed builds.

## Useful links

- [Read the Draftbit documentation](https://docs.draftbit.com)

## Related questions

- [Can Draftbit connect to my existing backend, database, and APIs?](https://draftbit.com/faq/can-draftbit-connect-existing-backend-database-apis/)
- [How does Draftbit protect my code, data, and secrets?](https://draftbit.com/faq/how-does-draftbit-protect-code-data-and-secrets/)
- [Can I add payments and subscriptions to a Draftbit app?](https://draftbit.com/faq/can-i-add-payments-and-subscriptions/)
