3Edit Web Builder iconLesson 10 · How web apps work

API keys explained: which ones are safe to share?

Public keys, secret keys, and where each belongs.

Payments, emails and databases all work through keys. Some are made to be seen; others must never leave the server. Learn the difference, what server routes do with secret keys, and the habits that keep your app and your customers safe.

About 9 minutes to readLast updated

By Humayun Rashed, founder of 3Edit

What an API key is

Your app doesn’t take card payments or send emails on its own. It asks a specialist service to do it: Stripe for payments, an email service for messages, Supabase for the database. An API is the doorway each service offers, and an API key is the password your app shows at that doorway, so the service knows which account the request belongs to.

That makes keys valuable. Whoever holds your secret payment key can act on your payment account; whoever holds your secret database key can skip your access rules. So the most important thing to learn about keys is where each one is allowed to live.

Two kinds of key

KindWhere it can liveExamples
Publishable (public) keyIn the browser. Anyone can see it, and it is built to be safe when they do.Stripe’s publishable key (pk_…); Supabase’s publishable key, which only reaches what your access rules allow
Secret keyOnly on the server. Never in a page, an app you ship or your code on GitHub.Stripe’s secret key (sk_…); Supabase’s secret key; your email service’s key

Server routes: where secrets do their work

If a secret key can’t be in the browser, how does your app use it? Through a server route: a small piece of your backend that runs on the server, out of sight. The browser asks the route to do a job, such as “start a payment for this basket”, and the route uses the secret key to do it, then sends back only the answer.

This is the backend from lesson 6 in action. The visitor’s browser never sees the key, and the server route can check the request before it acts: is this person signed in, is the price right, is this their own order? The 3Edit Agent builds server routes along with the rest of your full stack, and payments and email use your own keys.

Test keys and live keys

Many services give you two sets of keys. Stripe, for example, has test keys (pk_test_ and sk_test_) and live keys (pk_live_ and sk_live_). Test transactions don’t move real money, so you can place as many test orders as you like with Stripe’s test cards.

Build and test with test keys. Switch to live keys only when you are ready to take real payments, and test once more on your live site.

How 3Edit looks after your keys

  • A secure key form: you add keys with 3Edit’s secure key form. They are stored locally for the project, and the values are not sent to AI or saved in chat.
  • Left out of downloads and GitHub: project downloads and GitHub uploads leave out the env files where keys live, so you add your keys again wherever you host the project.
  • A secret scan before publishing: publishing runs checks first, including a private secret scan for keys in your site’s files.
  • Your Supabase connection, encrypted: your Supabase connection details are stored encrypted on your computer.

Good habits with keys

  • Never paste a secret key into the chat or a page. Use the secure key form, and ask the AI to use the key from there.
  • Ask where each key lives: “Which keys does my app use, and are any of them sent to the browser?” is a great question to ask the AI.
  • Rotate a leaked key at once: if a secret key ever ends up somewhere public, create a new one, revoke the old one and remove it from your code.
  • Keep admin access small: the fewer people and accounts with powerful keys or admin rights, the safer your app.
  • Read the full checklist: the security basics guide covers keys, access rules and a self-check you can run in your browser.

Try it in 3Edit.

These prompts check and improve how a project handles keys. Use a project that already takes payments or sends emails, such as a store from the Ecommerce Store kit, or ask them about any project you have built.

  1. 1List the keys

    List every key and secret my project uses. For each one, tell me which service it belongs to, whether it is publishable or secret, and where it is used: in the browser or only on the server.

  2. 2Check nothing leaks

    Check that no secret key is sent to the browser, written into a page or saved in a file that would go to GitHub. If you find one, move it to a server route and explain the change in plain words.

  3. 3A safe server route

    Explain how my checkout works, step by step: what the browser sends, what the server route checks before it starts the payment, and which key it uses. Make sure the price is worked out on the server, not taken from the browser.

The last prompt teaches a habit worth keeping: anything that matters, such as a price, a discount or who owns an order, is decided on the server, where visitors can’t change it.

Questions people ask.

An API key is a password your app uses to work with another service, such as payments, email or a database, so the service knows which account a request belongs to.

Only publishable keys, which are built to be seen, such as Stripe’s publishable key and Supabase’s publishable key. Supabase’s publishable key only reaches what your access rules allow, so turn row level security on for every table.

A small piece of your backend that runs on the server. The browser asks it to do a job, and it uses secret keys to do it, so the keys never reach the visitor’s browser.

Rotate it straight away: create a new key, revoke the old one and take it out of your code. The security basics guide explains the steps.

Keys saved with 3Edit’s secure key form are stored locally for the project, and the values are not sent to AI or saved in chat. Project downloads and GitHub uploads also leave out the env files where keys live.

Start vibe coding today.

Download 3Edit for Mac or Windows and build your first professional website in minutes.

Download now
macOSWindows