Guide · 2026-10-16

Stripe publishable key vs secret key: which can be public?

If a secret key is in your site

  1. In the Stripe Dashboard → Developers → API keys, roll the key immediately.
  2. Review recent activity for refunds, payouts and customers you don't recognize.
  3. Move the code that needs it to a server function.

A simpler option

If you only sell a few things, Stripe Payment Links need no keys in your code at all. To confirm payments on a server, use a restricted key with only the read permissions you need.

Check your site in 10 seconds

Free scan for leaked API keys, exposed .env files, link previews, SEO basics and security headers.