StoicBuilder

HandbookII the ForumClient vs server

IIthe Forum, The shape of an app

Client vs server

1 min readUpdated 28 November

In plain words

Your app runs in two places: the client is the visitor's browser, which anyone can inspect and edit, and the server is a machine only you control.

Where you see it

Open your browser's DevTools on your live app and the Sources tab shows the code behind every screen: that is the client. The Next.js route under app/api, or the Supabase Edge Function that charges a card, runs on the server, out of view.

components/LikeButton.tsxbrowser
"use client"; // this file ships to every visitor's browser export function LikeButton({ postId }: { postId: string }) { async function like() { await fetch(`/api/posts/${postId}/like`, { method: "POST" }); } return <button onClick={like}>Like</button>;}
The browser only asks. The server route decides whether the like counts.

What goes wrong

  1. Trusting a total the browser sent

    Anything the browser sends can be edited in DevTools first. A server that charges whatever total arrives will one day charge 0.01.

    const amount = body.total; // straight from the browser
  2. Hiding a button and calling it security

    Hiding Delete from non-admins only changes what the browser draws. The server still has to check who is asking before it deletes anything.

  3. Importing server-only code into a client component

    The build stops with an error about next/headers or fs, because the browser can't reach your server's files or read the incoming request. Keep that code in a server file and pass the result down.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Tell me which files in this project run in the browser and which run on the server. Move every price calculation, permission check and secret key into server code, so the browser only sends requests and shows results.

Quick check

Sign in to earn +10 XP for it

QuickBite's checkout sends the cart total from the browser to your server. What should the server do with it?

Got a prompt that touches client vs server?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.