Websites · Compared

Static site vs server side rendering

A static site, or static site generation, renders every page to HTML once when the site is built and serves those files from a CDN. Server side rendering builds the HTML on a server for each request. Static is faster and cheaper to host; server rendering suits pages whose content changes per visitor or per minute.

Both approaches send real HTML to the browser, which is good for search engines and first paint. The difference is when that HTML is made: once at build time, or fresh on every request.

· Co-founder

4 min read · Published

Static generation and server side rendering compared
QuestionStatic site (SSG, prerendering)Server side rendering (SSR)
When HTML is madeOnce, at build timeOn every request
Where it is served fromFiles on a CDNA running server or serverless function
Speed of first byteVery fast, cached at the edgeDepends on the server and its data calls
Fresh dataNeeds a rebuild or a request from the browserFresh on each request
Hosting costLow; storage and bandwidthHigher; compute for every request
Personal pages (accounts, carts)Rendered as a shell, filled in the browserCan be rendered per visitor on the server
Failure modeStale content until the next buildSlow or failed pages if the server struggles

What each one means

Static site generation runs the site's code once during the build and writes an HTML file for every route it knows. Those files, with their scripts and styles, go onto a content delivery network that serves them from a location near each visitor. Server side rendering runs the same kind of code on a server when a request arrives, fetches whatever data the page needs, and returns fresh HTML. Frameworks such as React Router support both, and let one site mix them: its prerender option turns known paths into files at build time, while other routes can stay dynamic.

How they differ in practice

A static page is ready before anyone asks for it, so the first byte arrives quickly and the server does no work per visit. The trade off is freshness: if prices change in the database, the static HTML still shows the old ones until the site is rebuilt, unless the page loads live data in the browser after it appears. Server rendering always shows current data, but each visit costs compute time, and a slow database call slows the page. After either kind of HTML arrives, the browser loads the JavaScript and hydrates the page so buttons and forms work.

When to choose which

Most small business pages, such as home, services, about, contact and blog posts, change rarely and suit static generation. Pages that depend on the visitor, such as an account area, an order history or an admin screen, can be a static shell that loads the person's own data in the browser after sign in, or be rendered on the server. Server rendering earns its cost on pages with many dynamic URLs that must be indexed with fresh content, such as a large listings site. A booking site with a dozen pages rarely needs it.

Common mistakes

Calling a site static because it has no database, or dynamic because it has a contact form; the terms describe when HTML is made, not whether a site has features. Prerendering pages that show prices, then forgetting to rebuild after a price change. Rendering personal data into static HTML, where a CDN could cache it for the next visitor. Putting secrets in code that runs in the browser because a framework blurs which code runs where. And reading browser only values, such as the window size or the time, during the first render, which causes hydration mismatches.

Where it shows up in OneCraft

A OneCraft website is a React Router, Tailwind and shadcn/ui project written as code. Every build runs a typecheck, ESLint and the production build, then a layout check opens every prerendered page in headless Chromium at 375, 768 and 1280 pixels and fails on sideways overflow and on runtime or hydration errors. Publishing, on a paid plan, builds a chosen version and copies it to the CDN. When a capability needs data, such as bookings or orders, the agent gives the site its own database with row level security on every table, so changing data does not depend on rebuilding pages.

Questions people ask

Is a static site bad for SEO?

No. Search engines receive complete HTML from a static site, which is ideal for crawling and indexing. What hurts SEO is HTML that only appears after JavaScript runs, or pages whose content is out of date. Static generation with good titles, descriptions and internal links is one of the most search friendly ways to publish.

Can a static site have a login and a database?

Yes. The pages are static files, but after they load, the browser can sign a person in and read or write data through an API such as a Supabase project, with access rules in the database deciding what each person sees. Many modern small business sites work exactly this way.

What is incremental static regeneration?

It is a hybrid offered by some frameworks and hosts: static pages are rebuilt in the background after a set time or when data changes, so visitors get static speed with fairly fresh content. It depends on host support and adds complexity, so smaller sites usually rebuild on publish instead.

Does server side rendering cost more?

Usually. Each request runs code on a server or serverless function and often queries a database, so cost grows with traffic. Static files cost only storage and bandwidth. For a small site the difference may be small, but under a traffic spike static hosting scales with little extra cost.

What is the difference between SSR and client side rendering?

With server side rendering the server sends finished HTML. With client side rendering the server sends a nearly empty page and JavaScript builds the content in the browser. Client side rendering is slower to show content and harder for some crawlers, which is why most frameworks now render on the server or at build time first.

Make one with websites

The button opens the generator with this use case already described. Change the wording to match your own.

Create a website with OneCraft

Related questions

Sources

Written and checked by the OneCraft team. Last checked .