methodEngineering & architecture

Client-Side Rendering (CSR)

Client-side rendering uses JavaScript in the browser to create or update a route's main interface after its document arrives.

Download Markdown (.md)

01What it means

Client-side rendering (CSR) produces a view primarily in the browser. An initial HTML document loads JavaScript, the application obtains data, and code creates or changes DOM content. CSR can describe an initial route or later transitions; it does not require that every part of the product use the same rendering method.[1][2]

Browser-side view creation The document shell loads code and data before the client creates the view
  1. 01Document shellHTML, styles, script references
  2. 02Download codeParse and execute
  3. 03Establish stateFetch route data
  4. 04Render DOMCreate or update view
  5. 05Update locallyState and route changes

CSR may describe the initial route, later transitions, or only part of a hybrid product.

02Why it matters

CSR enables rich stateful interfaces and moves rendering capacity to users' devices, but content and interaction may depend on script download, parsing, execution, and data requests. These costs vary sharply with device and network conditions.

03When to use it

Use CSR for private, interaction-heavy views where data is naturally fetched after authentication and persistent browser state provides value. Avoid making essential content depend on a large client runtime when server or static HTML can deliver it more reliably.

04How it works

  1. The server returns a document shell and references to scripts and styles.
  2. The browser downloads, parses, and executes the application code.
  3. Client code establishes state and requests any data needed for the route.
  4. The application creates or updates DOM nodes for the current view.
  5. Later state and route changes trigger targeted client renders.

05A practical example

Example

An internal analytics workspace renders charts after the signed-in browser obtains user-specific data. The team keeps the sign-in and error pages server-rendered, splits the chart code, and provides clear loading and retry states.

06Where it breaks

Initial content can be delayed by JavaScript and request waterfalls, low-powered devices pay execution cost, and script failure can leave an empty shell. Search and sharing behavior may require separate handling, and complex client state creates debugging overhead.

Common mistakes

  • Assuming client rendering is fast because navigation feels quick on a development laptop.
  • Shipping one large bundle before showing essential content.
  • Leaving an empty page when scripts or data requests fail.
  • Using CSR for every route instead of choosing rendering per user need.

07Sources

  1. Rendering on the Webweb.dev · Official technical guidanceRendering on the Web
  2. Client-side web APIsMDN Web Docs · Official technical documentationClient-side web APIs
View saved topics

Start typing to search titles, definitions, categories, and frameworks.