Tutorial

Frontend vs backend, explained

Every app is two halves: the part you touch and the part that thinks. Here's where the line runs, and what lives on each side.

The split

  • Frontend is everything the user sees and touches: pages, buttons, forms, animations. The code runs in the visitor's browser (or in the app on their phone). Built with HTML, CSS, and JavaScript, plus frameworks like React or Vue.
  • Backend is everything hidden: the server that receives requests, the logic that decides what to do, and the database that remembers. Built with languages like Python, PHP, Java, or JavaScript running on Node.js.
  • The database is the third piece people forget: permanent storage for users, posts, orders, everything the app must remember tomorrow.

The two halves talk through APIs, which you met in the previous tutorial.

Trace one login through both sides

Watch what happens when you tap "Log in":

  1. Frontend: the form collects your email and password, checks they're filled in, and sends a request.
  2. API: the request travels to an endpoint like POST /login.
  3. Backend: the server checks the credentials against the database. Passwords are compared as hashes; the server never trusts the browser's word.
  4. Database: stores the user record and the session.
  5. Back to frontend: the server answers "yes" plus a session token; the app shows you logged in.

The rule of thumb: the frontend controls the experience, the backend owns the truth. Anything security-critical must be re-checked on the server, because browser code is visible to everyone.

Which should you learn first?

Honest answer: frontend, because the feedback loop is instant. Change HTML, refresh, see it. That visible progress keeps beginners going through the hard parts. Learn HTML, then CSS, then JavaScript, then peek at a backend by building a tiny API. There is no wrong door, but the visible one is friendlier.

Developers who do both are called full-stack. Nobody starts there; they start on one side and grow into the other.

Trace two: a visitor sends the contact form

The login trace above starts with a known user. A contact form starts with a stranger, and the site has to decide whether to trust what arrives. Follow one submission from the click onwards.

  1. The visitor fills in name, email address, and message, then clicks the send button. The form they see, the order of the fields, and the button itself are frontend work running in the browser.
  2. The browser checks the fields before anything travels. Empty required fields get flagged next to the field itself, and an email address without the expected format gets a message asking the visitor to fix it. If a check fails, no request leaves the browser yet.
  3. Once the fields pass, the browser sends a request to the server, usually a POST request to the form endpoint, carrying the values the visitor typed.
  4. Server code receives the request and checks the fields again. The repeat matters because browser checks run on the visitor computer, where anyone can bypass them. The server also applies its own spam and abuse checks at this point.
  5. The backend then writes something down. On many small sites it builds an email with the message and sends it to the site owner inbox. Other sites also save the message in the database, so a copy survives even if the email goes astray.
  6. The server sends a response back to the browser with the outcome: accepted, or rejected with a reason.
  7. The frontend shows the result. A successful submission gets a confirmation message on the page. A rejected submission gets an error beside the field that failed, with the typed text still in place so the visitor can correct it.

Notice where each failure surfaces. A formatting mistake gets caught in the browser within a second and costs the server nothing. A delivery problem shows up at step five, on the server, where the visitor cannot see it. That is why site owners test forms by receiving the email, and why a confirmation message on screen only proves the first half of the journey worked.

Which side handles everyday tasks

TaskSideReason
Caching a pageBothThe server can store a ready made copy of a page and serve that copy to the next visitor. The browser also keeps copies of files such as images on the visitor device, so repeat visits load less data.
Checking a passwordBackendThe comparison happens against the stored hash in the database, on the server. Moving this check into the browser would hand the stored data to every visitor.
Resizing an uploaded photoBackendThe file arrives at the server, and the server creates the smaller sizes the site displays. The browser may show a preview before upload, and the stored resizing still happens on the server.
Sending a receipt emailBackendThe server sends the email after it saves the order. The sending has to work even if the buyer closes the browser tab the moment the payment completes.

A pattern runs through the table. Work that has to be trusted, remembered, or finished after the visitor leaves belongs on the server. Work that shapes what the visitor sees and touches in the moment belongs in the browser. When you plan a new feature, asking which of those two descriptions fits will usually place the feature on the right side before any code gets written.

Frequently asked questions

Can JavaScript be backend?

Yes. In the browser JavaScript is frontend; through Node.js it runs on the server as backend. It's the one language that comfortably lives on both sides.

Is the database part of the backend?

Effectively, yes. People say "backend" to mean the server, the logic, and the database together.

Do I need both for a simple website?

No. A marketing site or blog can be frontend-only. You need a backend when the site must remember things: users, orders, comments, messages.

Last verified: October 24, 2026, against MDN Web Docs. These are stable industry definitions.

Need both halves built right?

We're full-stack: interfaces users love, backends that hold up.

Get a quote →

← All tutorials