Bolt.new environment variables vs Secrets: which API keys are safe?
· PlugLeak
Bolt stores environment variables in the project .env file, which browser code can read, and Secrets for server functions only. Which API keys can sit in .env, which must be Secrets, and how to check a published Bolt app.
Bolt keeps values in two places. Only one of them stays off the published site.
Environment variables live in the project .env file. Bolt says project code can read them while the app runs, including code that runs in the visitor's browser. If that code reads a value, the value is part of what the published site sends to anyone who opens it (Secrets).
Secrets are a different screen. Open the project, click the database icon in the top menu, then Secrets. Secrets only work with server functions, which Bolt also calls edge functions. Bolt reads a secret only when a server function needs it, and it does not write that value into your project files, the code that runs in the browser, or the published site.
The Secrets page is missing until a database is connected. Server functions rely on that database, so you cannot add server functions or secrets before one exists. Bolt creates a database when the project needs one. If it has not, ask Bolt to add one.
Who can see each one
| Access | .env (environment variables) | Secrets |
|---|---|---|
| Who can open it | Hidden from view-only collaborators. Editors and co-owners can still see the file. | Individual account: project owner only. Team: project owner, co-owners, and team admins. Editors and viewers get "Project admin access required." |
| Where the value goes | The project .env file, which is part of the project code. Browser code can read it. A browser read is sent to visitors of the published site. | Server functions only. After you save, Bolt does not show the value again, and it does not write it into .env, other project files, or the published site. |
| Use it for | Values the app reads directly, including in the browser. With a database connected, Bolt fills in the web address and public key and locks those two so you cannot edit them by hand. | Values only a server function needs, such as a payment provider's secret key or an email service's API key. |
Hiding .env from a viewer does not hide a value the browser already ships. The project owner, editors, and co-owners can publish. Viewers can open the published site and cannot publish it (Publish your project).
Three names Bolt's database intro lists together
The introduction to databases lists these names and says environment variables keep them private (Introduction to databases):
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY
They are not the same kind of value. That page also says a codebase can be shared or published without exposing private credentials, because the values live outside the files that get committed. The Secrets page is the one to follow for a live site: .env is part of the project code, browser code can read it, and a value the browser reads is sent to visitors. A VITE_ name is inlined into the bundle whether or not git ignores the file.
The URL and the anon or publishable key are the public pair. The service_role key is not. Supabase says SUPABASE_SERVICE_ROLE_KEY and SUPABASE_SECRET_KEYS bypass Row Level Security, so use them in Edge Functions and never in a browser (Edge Function secrets). The service_role guide is the removal and rotation when that key has already shipped.
A VITE_ prefix means public
Those VITE_ names are Vite's prefix. Bolt's supported-technologies page says it supports browser JavaScript frameworks in general, and Expo for mobile apps, so confirm the project in front of you (Supported technologies). A vite.config file, or code that reads import.meta.env, means Vite. The prefix rule belongs to the bundler. The full table, including NEXT_PUBLIC_ when the project is Next.js, is the NEXT_PUBLIC_ and VITE_ guide.
Vite exposes variables prefixed with VITE_ in client source after bundling, and it statically replaces import.meta.env at build time. VITE_* variables should not contain sensitive information such as API keys, because the values are bundled into your source. In the docs' example, import.meta.env.VITE_SOME_KEY is the string from the env file, and import.meta.env.DB_PASSWORD is undefined (Env variables and modes).
# Inlined into the JavaScript visitors download.
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=sb_publishable_...
# Not exposed on import.meta.env. Still the wrong file for this key.
SUPABASE_SERVICE_ROLE_KEY=sb_secret_...An unprefixed name stays off import.meta.env. That does not make .env a secret store. Editors and co-owners can open the file, and any browser code that reads the value still ships it. For production deployments, Vite says to consider a backend server or a serverless or edge function to secure secrets. In Bolt, that function is a server function, and the value belongs in Secrets.
Changing .env after a build does not rewrite JavaScript you already published. Publish an update, then search the live files.
What can sit in .env
| Value | In .env or VITE_ |
|---|---|
Supabase project URL, publishable key (sb_publishable_), or legacy anon key. Bolt fills in the web address and public key and locks those values. Supabase says the publishable key and the anon key are safe in a browser when Row Level Security is on. The key will still be visible. The RLS checklist is how to check every table. Telling a publishable key from a secret is the Bolt Supabase API key guide. | OK only with RLS on every table |
Stripe publishable key (pk_, including pk_test_ and pk_live_). Stripe says only publishable keys are safe to expose outside your application's back end (API keys). | OK |
What must be a Secret
These are credentials a visitor should never receive. Bolt says not to paste secret values into project code, and to add them as secrets instead. Vite says not to put API keys in VITE_. Read them from a server function.
| Value | Where it goes |
|---|---|
Stripe secret keys (sk_, including sk_test_ and sk_live_) and restricted keys (rk_). Stripe says you are responsible for protecting them. Bolt's Stripe setup asks for a secret key — test keys start with sk_test_ — and processes payments in edge functions (Stripe for payments). | Secrets, then a server function |
| OpenAI and Anthropic API keys. Bolt lists calling an external AI API such as OpenAI as server-function work (Server functions). | Secrets, then a server function |
| Resend and other email API keys. The Secrets page uses Resend as the example of a key you add there. Server functions are also where Bolt lists transactional email. | Secrets, then a server function |
AWS keys (search published JavaScript for AKIA) and GitHub tokens. Bolt lists receiving webhooks from GitHub as server-function work. Neither belongs in browser code. | Secrets, then a server function |
Supabase service_role key or sb_secret_ key. Either one bypasses Row Level Security. | Edge function environment only. Not .env, and not a VITE_ name. |
If the database is a Supabase project you connected, Supabase runs the app's server functions as edge functions (Supabase for databases). Read a secret inside that function with Deno.env.get:
const key = Deno.env.get("RESEND_API_KEY");Hosted Edge Functions already receive SUPABASE_SERVICE_ROLE_KEY and SUPABASE_SECRET_KEYS. Read those with Deno.env.get inside the function. Do not copy them into .env or into client code. Supabase says a new production secret is available to the function immediately, so you do not redeploy the function only to pick up that new value.
Do not create a secret whose name starts with SUPABASE_. Bolt reserves that prefix for its own database connection and you cannot delete those secrets. Supabase also rejects a secret name that starts with SUPABASE_, because that prefix is reserved for values it injects. For Stripe, OpenAI, Resend, and the rest, use the name Bolt asks for, such as RESEND_API_KEY. Names are case-sensitive. The value is hidden as you type.
Deleting a secret in Bolt removes the value from Bolt. A server function that still uses that name stops working until you add it back. Deleting it does not revoke the key at the provider.
Check a published Bolt app
Open the live URL, not the Bolt editor. In DevTools, use Sources and search across loaded files, or open a script in Network and search the response. Search for:
sk_live_(alsosk_test_andrk_, which are Stripe secrets too;pk_live_andpk_test_can be there on purpose)sk-proj-sk-ant-AKIAsb_secret_eyJ
eyJ is the start of a JWT. The payload is the middle segment. It is base64url, not encryption. Decode it on your own machine. Do not paste a secret key into a website or into the Bolt chat.
node -e "console.log(Buffer.from(process.argv[1], 'base64url').toString())" 'MIDDLE_SEGMENT'Read the role field. anon is the public legacy key, and it is expected in the client only together with Row Level Security. service_role is the emergency. sb_publishable_ is the public newer key. sb_secret_ is not. The Bolt Supabase API key guide is the rest of that classification.
Then open https://your-domain/.env. You want a 404, or the same HTML as the app. Lines of KEY=value mean the file is public. An HTML shell on an unknown path is only a rewrite. Do the same for /.git/config: a [core] section in the body means that file is public.
Fix, in this order
Revoke or rotate the key at the provider before you treat a code edit as the fix. GitHub's remediation tutorial says you should consider any leaked secret immediately compromised. Removing it from the codebase, pushing a new commit, or deleting and recreating the repository does not prevent it from being exploited. Revoke it with the provider (Remediating a leaked secret). If taking the app down is the problem, that same tutorial says you can generate the replacement first, point the app at it, and then revoke the old value. Either way, deleting the line is not the revocation.
- Revoke or rotate the leaked key in the provider's dashboard. Stripe, OpenAI, Anthropic, Resend, AWS, Supabase, and GitHub each do this in their own console. A key that reached a published bundle is already copied if anyone saved the file.
- Move the call into a server function. The project needs a database, or Bolt cannot add the function or the secret. Paste this into Bolt:
Move every call that uses a secret API key out of browser code and out of any VITE_ variable. Put those calls in a server function (edge function). Read each key from Secrets, not from the project .env file and not from import.meta.env. If this project uses Supabase, read the secret with Deno.env.get("NAME") inside the edge function. Do not write secret values into any project file. Leave only public values in .env: the Supabase URL, the anon or publishable key, and a Stripe publishable key that starts with pk_. Do not create a secret whose name starts with SUPABASE_. - Store the new key on Secrets: database icon, then Secrets. The name must match what the function reads, including case. Do not put the new value back in
.envor give it aVITE_name, or the next publish ships it again. - Publish the site again. Bolt deploys a server function when it creates or updates the function. Changes you make in the project are not applied to the published site until you open the Publish menu and click Update (Publish your project).
- Search the live JavaScript again, and open
/.envagain. Old bundles can keep the previous string until the update is what the URL serves.
Scan the live URL
The free scan is at https://plugleak.com/#scan. For a Bolt app, the same check is on /scan/bolt. It is a passive GET of the page and same-site JavaScript (max 25 files / 12 MB). It checks /.env, /.git/config, security headers, and TLS. It detects Stripe, OpenAI, Anthropic, and AWS keys, GitHub tokens, PEM private keys, sb_secret_ keys, and service_role JWTs.
It does not test Row Level Security or grants, query the database, log in, or crawl. A clean scan does not tell you whether the anon or publishable key is safe. That answer is the RLS checklist. How the free scan works lists every request.
FAQ
Where do I put API keys in Bolt?
Bolt has two places. Environment variables live in the project .env file. Project code can read them, including browser code, and a value the browser reads is sent to anyone who opens the published site. Secrets are under the database icon, then Secrets. They only work with server functions, and Bolt does not write the value into project files, browser code, or the published site. Put a Supabase URL, an anon or publishable key, and a Stripe pk_ key in .env. Put Stripe sk_ and rk_ keys, OpenAI, Anthropic, Resend, AWS, a Supabase service_role or sb_secret_ key, and GitHub tokens in Secrets, and call them only from a server function. You need a database connected before the Secrets page exists.
Are Bolt.new environment variables secret?
No, not from visitors, and not from every collaborator. Bolt hides the .env file from view-only collaborators. Editors and co-owners can still open it. If browser code reads a value, that value is in what the published site sends. In a Vite app, a VITE_ prefix is public: Vite inlines it into the client bundle at build time.
Is a Supabase anon key in VITE_ a leak?
The legacy anon key and the publishable key (sb_publishable_) are meant for the browser. Bolt fills the public database address and public key into .env. They are safe only with Row Level Security on every table. A service_role JWT or an sb_secret_ key is not. Classification is on /guides/bolt-supabase-api-key-visible. Policy checks are on /guides/supabase-rls-checklist.
I removed the key from my Bolt project. Is that enough?
No. GitHub's leaked-secret tutorial says to treat a leaked secret as compromised. Removing it from the code, pushing a new commit, or deleting and recreating the repository does not revoke it. Revoke or rotate it at the provider, move the call into a server function, store the new value in Secrets, publish an update, and search the live JavaScript again.
Does the free scan check Row Level Security on a Bolt app?
No. The scan at https://plugleak.com/#scan is a passive GET of the page and same-site JavaScript (max 25 files / 12 MB). It checks /.env, /.git/config, security headers, and TLS, and it detects Stripe, OpenAI, Anthropic, and AWS keys, GitHub tokens, PEM private keys, sb_secret_ keys, and service_role JWTs. It does not test Row Level Security or grants, query the database, log in, or crawl. The Bolt page is https://plugleak.com/scan/bolt.
Sources
Check your app now — free, passive, about 20 seconds.
Same scanner as the homepage scan. Paste the live URL. It reads what a visitor already downloads. It does not log in or query your database.
Related guides
- GitHub token in the frontend
- Stripe secret key in the frontend
- CheckVibe alternatives
- OpenAI API key in the frontend
- Claude Code settings.local.json keys
- v0 app security checklist
- Cursor app security checklist
- NEXT_PUBLIC_ and VITE_ API keys
- Lovable app data exposure check
- Supabase 42501 permission denied
- Supabase RLS checklist
- Bolt Supabase API key visible
- Supabase service_role key exposed
- Lovable app security check
- Is my vibe-coded app secure?
Scan by builder