StoicBuilder

HandbookII the ForumServer and client rendering

IIthe Forum, The shape of an app

Server and client rendering

1 min readUpdated 28 November

In plain words

Server rendering builds a page's HTML on the server before sending it, while client rendering sends an empty shell and builds the page in the browser with JavaScript.

Where you see it

Right-click your Lovable app and choose View Page Source: the page is almost empty apart from one <div id="root">, because React builds everything in the browser. Do the same on a Next.js site and the page's text is already there.

app/feed/page.tsxserver
// A Server Component: runs on the server and sends finished HTMLexport default async function FeedPage() { const posts = await getPosts(); return <ul>{posts.map((p) => <li key={p.id}>{p.content}</li>)}</ul>;}
No loading spinner needed: the posts are in the HTML before it reaches the browser.

What goes wrong

  1. useState in a Server Component

    Next.js stops with an error saying the hook only works in a Client Component. Add "use client" to the small interactive piece, not to the whole page.

  2. Link previews that all look the same

    Slack, WhatsApp and LinkedIn read the first HTML without running JavaScript. In a browser-built app every page shares the same shell, so every link gets the same generic preview.

  3. Hydration errors

    React expects the browser's first draw to match the server's HTML exactly. A date or random number that differs between the two triggers "Hydration failed" in the console.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Tell me which pages in this app are rendered on the server and which in the browser, and why. Fetch data in server components where the framework supports it, and mark only the interactive pieces as client components.

Quick check

Sign in to earn +10 XP for it

Every Quill note you share in Slack gets the same generic preview. Quill is a Lovable app. What's behind it?

Got a prompt that touches server and client rendering?

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

Check your own prompt

Free, no sign-up.