Skip to content
DevelopmentBeginner6 min read

Frontend vs Backend

The split isn't visible versus invisible. It's which computer the code runs on — and that single fact explains almost every rule that follows from it.

Written by Daksh BathlaFounder — Technology, Product & Business
Published 29 May 2026 · Updated 1 August 2026

The line that matters

Frontend code runs on the user's device, inside their browser. Backend code runs on a machine you control. That's the whole distinction, and every practical consequence follows from it.

The consequence that matters most: anything on the user's device can be read and changed by that user. Not by a hacker — by any curious person with developer tools open. Which means frontend code can never be trusted with a secret or with a final decision.

Who owns what

Responsibilities by side
ResponsibilitySideWhy
Layout and stylingFrontendIt's about the device it's shown on
Instant feedback on a formFrontendWaiting for a server to say a field is empty is a bad experience
Deciding if a password is correctBackendThe check and the stored value must both be out of reach
Deciding what a user may seeBackendHiding a button hides a button, not the data
Talking to the databaseBackendCredentials can't exist on a user's device
Charging a cardBackendAmounts sent from a browser can be edited
Sending emailBackendMail credentials are secrets

Why the line looks blurry now

Modern frameworks let you write both sides in one language, in one project, sometimes in one file. That's a genuine convenience and a genuine source of confusion, because the file no longer tells you where the code runs.

Frameworks handle this with explicit markers — a directive at the top of a file, a naming convention, a folder. Learn your framework's marker early, because the security rule hasn't changed at all: a function that reads a secret must never end up in a bundle shipped to a browser.

the-question-to-ask.ts
// Before writing any function, answer one question:// Does this need something the user must never have?////   Database credentials   -> backend//   API keys               -> backend//   Another user's data    -> backend//   The current scroll pos -> frontend//   Whether a menu is open -> frontend

Placing a new feature

  1. Ask what the feature needs access toSecrets, other users' data, or money mean backend. No exceptions worth taking.
  2. Ask how fast it must feelAnything that should respond within a keystroke belongs on the frontend — as a convenience layered over a backend check.
  3. Assume both, thenMost features are a frontend layer for responsiveness plus a backend layer for truth. Duplicated validation isn't waste; it's the design.

Common mistakes

  • Storing an API key in frontend code, or in an environment variable that gets bundled into it
  • Enforcing permissions by hiding UI
  • Trusting a price, a user ID, or a role that arrived from the browser
  • Assuming a shared language means a shared trust boundary

Key takeaways

  • The split is about which computer runs the code, and everything follows from that
  • Anything on the user's device is readable and editable by the user
  • Secrets, permissions, and money live on the backend without exception
  • Duplicated validation on both sides is correct, not redundant

Try it yourself

Pick a feature in your product and list what it touches. Mark each item as "safe for a stranger to see" or not. Everything in the second column defines the backend half of that feature.

TERMS USED HERE