Understanding a secret prompt
When Lovable asks you for a secret, the chat message explains which secret it needs and why. Before entering a value, check:- The secret name. For example,
STRIPE_SECRET_KEYorOPENAI_API_KEY. The name is usually the exact environment variable your Edge Function will read. - The chat message before the prompt. Lovable explains what the current change needs the secret for, such as calling a specific API, authenticating with a provider, or signing webhooks, and where to get the value.
- The provider’s dashboard. If you’re unsure what the value should be, open the provider’s website (Stripe, OpenAI, Resend, and so on) and look for the API key or credential of the same name. The input field shows an example of what a well-formed value looks like, and warns if what you enter doesn’t match the expected format. The warning never blocks you, so you can still submit a valid key the format check guessed wrong.
Manage secrets
The Secrets view lists each secret’s name and creation date. Values are never shown.- Add secret opens a dialog where you can enter one or more name and value pairs.
- Delete, in the secret’s … menu, removes a secret. This cannot be undone; if a feature still needs the value, your app breaks until you add it again.
- Secrets are write-only: after you save a secret, its value can never be viewed again in Lovable, only replaced or deleted. If you lose a key, generate a new one at the service that issued it. Secrets are not copied when a project is remixed.
- Lovable: managed by Lovable and required for the platform to work. These cannot be deleted.
- Not in use: another secret with the same name takes precedence at runtime.
LOVABLE_API_KEY secret, used by built-in AI, has a Rotate action. If you suspect the key has been exposed, rotate it: Lovable issues a new key and updates your Edge Function environment automatically. Rotating requires editor access or above.
Workspace build secrets
On Enterprise plans, build secrets set for the whole workspace appear in this list too, sorted alphabetically alongside your project secrets. They sit in a dimmed row with your workspace avatar next to the name.- Workspace secrets are read-only here. You see the name, never the value. The Created column can be blank for older workspace secrets.
- The only action is View workspace secrets, which opens Settings → Build & deploy → Build secrets. Add, change, and delete them there, as a workspace admin or owner.
- Seeing these rows depends on your workspace role, not on your access to this project. You need workspace editor access or above, so external collaborators manage the project’s own secrets without seeing the workspace ones.
- A project secret can use the same name as a workspace secret. The list then shows only the project row, marked with a warning icon, and your app runs with the project value. While a project builds, the workspace value still applies, because project secrets take no part in builds.
Secrets vs. VITE_ environment variables
Lovable’s Secrets manager is for backend values only: values used by Edge Functions and server-side integrations. Anything prefixed with VITE_ is a build-time, browser-exposed value and must live in your project’s .env file instead, not in Secrets.
- Backend secrets (use Secrets):
STRIPE_SECRET_KEY,RESEND_API_KEY,OPENAI_API_KEY, third-party service credentials, and anything that must never reach the browser. - Frontend variables (use
.env): anything prefixed withVITE_, such asVITE_SUPABASE_URLandVITE_SUPABASE_PUBLISHABLE_KEY. These are embedded into the client bundle at build time and are safe to be public. You can find and edit them in the.envfile in Lovable’s code editor or in your synced Git repository.
VITE_-prefixed name in Secrets, Lovable rejects it with a message like “VITE_ prefixed variables are build-time browser values and should be defined in .env files, not in secrets.”
Reserved secret name prefixes
The following name prefixes are managed automatically by the built-in backend and cannot be created or overwritten in the Secrets UI:SUPABASE_: for exampleSUPABASE_URL,SUPABASE_ANON_KEY,SUPABASE_SERVICE_ROLE_KEY,SUPABASE_DB_URL. These are populated by Lovable when the built-in backend (Cloud), or a connected Supabase project, is enabled.LOVABLE_: reserved for Lovable-managed values such as the Lovable API key used by built-in AI.
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")).
If your project uses an external Supabase connection instead of the built-in backend, secrets are managed in Supabase: the backend view shows a Manage secrets button that opens your Supabase project’s dashboard.
FAQ
Can I view a secret's value after saving it?
Can I view a secret's value after saving it?
No. Secrets are write-only: you can replace or delete a secret, but never read its value back. If you lose a key, generate a new one at the service that issued it.
Are secrets copied when I remix a project?
Are secrets copied when I remix a project?
Lovable-generated keys are recreated fresh in the remixed project. Manually added secrets are not copied over, so re-enter them in the new project.
Where do my secrets get used?
Where do my secrets get used?
Secrets are injected into your project’s Edge Functions and server-side integrations at runtime. They are never included in your frontend code or exposed to the browser.
Should I put my API key in a secret or in .env?
Should I put my API key in a secret or in .env?
If the value must stay private (payment keys, AI provider keys, service credentials), use Secrets. If it’s a
VITE_-prefixed build-time value that is safe to be public, it belongs in .env.