Guide · Stripe keys · Updated
Is My Stripe Key Safe in My Frontend? pk_live vs sk_live in Lovable, Bolt and v0 Apps
Stripe gives you a public key for the browser and secret keys for your server. The public one is fine to share. A secret one in your frontend lets a stranger use your Stripe account. Here is which key is which (from Stripe's own docs), how vibe-coded apps leak the wrong one, two payment traps that cost money even when your keys are fine, and how to check your live app.
1. Which Stripe keys are safe in the browser
Stripe's docs are clear: only publishable keys are safe to expose outside your backend. Everything else stays on your server.
| Key | Starts with | Safe in the browser? | Where it belongs |
|---|---|---|---|
| Publishable key | pk_live_... / pk_test_... | Yes | Browser, Stripe.js, mobile apps |
| Secret key | sk_live_... / sk_test_... | No | Server only. Full access to all Stripe APIs |
| Restricted key | rk_live_... / rk_test_... | No | Server only. Only the permissions you pick |
| Webhook signing secret | whsec_... | No | Server only. Proves a webhook came from Stripe |
- Publishable key (
pk_): made for Stripe.js and checkout forms. Stripe says it can create tokens or PaymentMethods from card details but cannot create charges or read account data. Seeing it in DevTools is normal. - Secret key (
sk_): Stripe says it has unrestricted permissions on all Stripe APIs. With it, someone could make charges, read customer data or mess with your setup. - Restricted key (
rk_): you choose its permissions, so a leak does less damage. Stripe still says it is not safe to expose. Stripe now recommends restricted keys over full secret keys for new work. - Webhook signing secret (
whsec_): not an API key, but still a secret. Your server uses it to prove a webhook really came from Stripe.
Test keys (sk_test_) cannot move real money, but they still open your test data and are a sign that the live key may end up in the same place.
Sources: Stripe: API keys · Stripe: Best practices for managing secret API keys
2. How vibe-coded apps leak sk_live_
Nobody plans to put a secret key in the browser. It usually happens like this:
- You paste the key into the chat instead of the builder's secret form, and the AI writes it straight into a file. Lovable's docs warn: never paste your Stripe key into the project chat as a message.
- The AI calls Stripe from a React component to "make checkout work", which needs the secret key in browser code.
- The key goes in a public env var like
VITE_STRIPE_SECRET_KEYorNEXT_PUBLIC_STRIPE_SECRET_KEY. Those prefixes tell Vite and Next.js to copy the value into the JavaScript every visitor downloads. See which env vars end up in the browser.
The app works, checkout opens, and the secret key ships to everyone. Stripe also warns that people scan public code for Stripe keys, and that anyone can unpack an app to look for keys inside it.
Sources: Lovable: Connect your own Stripe account · Stripe: Best practices for managing secret API keys
3. Where the secret key should live (Lovable, Bolt, v0, Cursor)
- Lovable: Lovable's Stripe setup asks for a restricted key (
rk_) or secret key (sk_) in a Connect Stripe form. It stores it as a backend secret namedSTRIPE_SECRET_KEYand calls Stripe from edge functions, so the key is not in your app code. Most Lovable projects can also use built-in payments, where Lovable manages the keys for you. - Bolt: Bolt's Stripe integration asks for your secret key in a setup window and creates Supabase edge functions for checkout, webhooks and subscriptions. It needs Supabase (or Bolt Database) and user sign-in.
- v0, Cursor and other Next.js apps: call Stripe only from a Route Handler or Server Action. Store the key in an env var without
NEXT_PUBLIC_(for exampleSTRIPE_SECRET_KEY). - Any host: Stripe says to store keys in your host's secrets vault (or server env vars), keep them out of git, and use a restricted key with only the permissions you need.
The built-in setups are safe by design. Leaks usually come from custom Stripe code added later, or from an old build made before you switched to the proper setup. That is why you check the live app, not just the settings page.
Sources: Lovable: Stripe · Bolt: Stripe for payments · Stripe: Protect your keys
4. Two payment traps: the price and the success page
These are not key leaks, but they cost real money and AI builders make them often.
Trap 1: the browser decides the price
Stripe says: always decide how much to charge on the server, not the client, so customers cannot choose their own prices. If your checkout function takes an amount or price from the browser, someone can change it. Send only a product or plan ID, and let the server look up the real Stripe price.
Trap 2: the success page unlocks paid features
If your app gives paid access just because someone opened /success, anyone who types that address gets in free. Stripe also says you cannot rely on the landing page for fulfillment, because a buyer can pay and lose their connection before it loads. The fix is a webhook that checks the Stripe-Signature header with your whsec_ secret, then marks the user as paid in your database.
VibeCheck does not test your checkout or webhooks. Check these two by hand, or use the prompts below.
Sources: Stripe: Create a PaymentIntent · Stripe: Fulfill orders · Stripe: Verify webhook signatures
5. Check your live app in 60 seconds
Only check apps you own or have permission to test.
- Fastest: paste your live link at the top of this page. VibeCheck reads your homepage and the JavaScript files it loads and flags
sk_live_,rk_live_andsk_test_keys. It masks any key it finds. - By hand in Chrome: open your live site, right-click → Inspect, then press Ctrl+Shift+F (Cmd+Option+F on Mac) to search all loaded files. Search for
sk_live_,rk_live_,sk_test_andwhsec_. - Visit your checkout and paid pages too. Some code only loads on those pages. Run the same search there.
- Seeing
pk_live_is fine. That is the publishable key and it is meant to be public.
6. Found sk_live_ in your app? Do this now
- Rotate the key now. Stripe says to rotate an exposed key right away, even if you are not sure anyone saw it. In the Stripe Dashboard, open the API keys page, click ⋯ next to the key and choose Rotate key. You can keep the old key working for up to 7 days while you switch, but for a leaked key pick a short expiry.
- Move Stripe calls to the server and put the new key in a server-side secret (see section 3).
- Redeploy, then search your live site again to confirm the key is gone.
- Check Stripe's request logs for calls you do not recognize (click ⋯ on the key, then View request logs).
- Leaked a
whsec_secret? Roll it in the Webhooks section of the Dashboard.
More detail, plus OpenAI, Supabase and Google keys: I leaked my API key. What do I do now?
Sources: Stripe: Rotate an API key · Stripe: Handling compromised keys · Stripe: Roll endpoint secrets
7. Copy-paste fix prompts
Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. After you deploy, rotate any Stripe secret or restricted key that was ever in client code.
Search this whole project for sk_live_, sk_test_, rk_live_, rk_test_, whsec_, STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET. Remove every Stripe secret key, restricted key and webhook secret from client-side code and from any NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_ variable. Only the publishable key (pk_live_ or pk_test_) may be used in the browser. Move every Stripe call that needs a secret key into a server function (Supabase Edge Function, Next.js Route Handler or Server Action) that reads the key from a server-side secret. List every key you removed so I can rotate it in the Stripe Dashboard.
Make sure the browser never sends a price or amount to my checkout function. The browser should only send a product or plan ID. The server function must look up the Stripe price ID (or amount) from a fixed list or my database, then create the Checkout Session or PaymentIntent. Reject any unknown product ID. Show me the changed code.
Do not unlock paid features just because the user landed on the success page. Add a Stripe webhook function that verifies the Stripe-Signature header with the whsec_ signing secret (stored as a server secret) using the raw request body, then marks the order or subscription as paid in my database for that user. On the success page, read the paid status from my database. Keep the signing secret out of client code.
8. Check it for me
Paste your link into VibeCheck. In about 10 seconds it checks the JavaScript your live site sends to visitors for leaked keys (Stripe sk_live_, rk_live_ and sk_test_, plus OpenAI, Anthropic, Supabase service_role and more), checks if your public Supabase key can read open tables, and checks security headers, SEO basics and broken links.
It is a public, read-only check. It never asks for your code, your login or your Stripe account.
Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.
No tool can promise your app is 100% secure. VibeCheck catches common, costly mistakes before a stranger does.
9. FAQ
Is it safe to put my Stripe publishable key in my frontend?
Yes. Stripe says the publishable key (pk_live_ or pk_test_) is safe to put in front-end code. It can identify your account and turn card details into tokens or PaymentMethods, but it cannot create charges or read your account data.
What happens if my Stripe secret key is in my frontend code?
Anyone who opens your site can copy it from your JavaScript files. Stripe says a secret key (sk_live_) has unrestricted access to all Stripe APIs, so someone with it could make charges, read customer data, or issue refunds. Rotate it right away in the Stripe Dashboard, then move it to a server-side secret.
Is a Stripe restricted key (rk_live_) safe to expose?
No. Stripe lists restricted keys as not safe to expose. A restricted key limits what can go wrong because you choose its permissions, but it still belongs on your server, in your host's secrets, never in browser code.
Where should my Stripe secret key live in a Lovable or Bolt app?
In a backend secret, used only by server code. Lovable stores it as a backend secret named STRIPE_SECRET_KEY and calls Stripe from edge functions. Bolt's Stripe integration uses Supabase edge functions for checkout and webhooks. In Next.js (v0, Cursor), use a server route and an env var without the NEXT_PUBLIC_ prefix.
Is the webhook signing secret (whsec_) safe in the browser?
No. The whsec_ signing secret is how your server proves a webhook really came from Stripe. If it leaks, someone could sign fake "payment succeeded" events. Keep it in a server secret and roll it in the Webhooks section of the Stripe Dashboard if it leaks.
How do I check if my live app leaks a Stripe secret key?
Paste your live link into VibeCheck for a free scan. It reads the JavaScript your homepage loads and flags Stripe live secret and restricted keys (sk_live_, rk_live_) and test secret keys (sk_test_). You can also open DevTools, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search your loaded files for sk_live_ and rk_live_.
More questions? See the VibeCheck FAQ. Related guides: How to check if your API key is exposed · I leaked my API key. What do I do now? · Is NEXT_PUBLIC_ safe for API keys? · Sending receipts? Is my Resend key safe? · Clerk keys also start with sk_live_: is my Clerk secret key safe? · Is my Lovable app safe? · Is my Bolt app secure? · Is my v0 app secure? · Vibe coding security checklist.