Skip to main content
skill CX Codex

client-side-rendering — Claude Code skill: CSR for React

A skill that walks through client-side rendering in React: when CSR fits, and when your page loses on SEO and first paint.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add PatternsDev/skills --skill client-side-rendering -a claude-code
Open on GitHub

What client-side-rendering does

The skill activates on **/*.tsx and **/*.jsx files and breaks client-side rendering into steps. The server ships a bare container; markup, routing and API calls all happen in browser JavaScript. It includes a createRoot example with a component that ticks the clock through useEffect, plus a rundown of CSR trade-offs.

Performance gets its own section. Bundle size moves First Contentful Paint and Time to Interactive directly: while the script loads, the user stares at a blank screen. The skill suggests keeping the initial bundle within 100–170KB minified and gzipped, splitting code, and lazy-loading anything non-critical. For critical resources it shows the <link rel="preload" as="script" href="critical.js" /> directive in <head>.

The skill states its own limit: CSR does not suit public pages that need indexing, because a crawler may not wait for content to render. It points to SSR or SSG there instead. Another catch is duplicated logic — currency and date validation often drifts between client and server in different languages. Worth checking where your shared logic lives before you lean on this skill.

What it helps with

  • decide between CSR, SSR and SSG for a React app
  • keep the initial JavaScript bundle inside a budget
  • defer non-critical code with code-splitting and lazy loading
  • preload critical scripts before rendering starts
  • figure out why a crawler sees nothing in an SPA

Example prompts for the agent

  • Review my React app: should these public pages move from CSR to SSR?
  • Split my bundle with code-splitting to speed up first paint
  • Add a preload hint for critical scripts in the head

How to install client-side-rendering

1Skills CLI (Vercel)

npx skills add PatternsDev/skills --skill client-side-rendering -a claude-code

2Manually: put the files in place

~/.claude/skills/client-side-rendering/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/client-side-rendering/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about client-side-rendering

How do I install client-side-rendering in Claude?

Run npx skills add PatternsDev/skills --skill client-side-rendering -a claude-code. The skill lands in ~/.claude/skills/client-side-rendering/SKILL.md.

What does client-side-rendering do?

It teaches the agent client-side rendering in React: how CSR works, when to pick it, and how to keep a large bundle from wrecking first paint.

Which pages should avoid CSR?

SEO-critical and content-heavy pages: a crawler may not wait for the render, and users see a blank screen until JavaScript loads. The skill recommends SSR or SSG there.

Source text

SKILL.md · MIT
---
name: client-side-rendering
description: Teaches client-side rendering (CSR) for React applications. Use when building highly interactive apps where SEO is not a priority and the UI is driven by user actions.
paths:
  - "**/*.tsx"
  - "**/*.jsx"
license: MIT
metadata:
  author: patterns.dev
  version: "1.1"
related_skills:
  - "hooks-pattern"
  - "hoc-pattern"
---

# Client-side Rendering

In Client-Side Rendering (CSR) only the barebones HTML container for a page is rendered by the server. The logic, data fetching, templating and routing required to display content on the page is handled by JavaScript code that executes in the browser/client. CSR became popular as a method of building single-page applications. It helped to blur the difference between websites and installed applications.

## When to Use

- Use this for internal tools, dashboards, or SPAs where SEO is not a priority
- This is helpful when you need a fully interactive single-page application experience

## When NOT to Use

- For SEO-critical pages where search engines need server-rendered HTML to index content
- For content-heavy sites where users see a blank page until JavaScript loads and executes
- When Time to First Contentful Paint is a key metric — CSR defers all rendering to the client

## Instructions

- Keep initial JavaScript bundles small (< 100-170KB minified/gzipped) for fast First Contentful Paint
- Use code-splitting and lazy loading to defer non-critical JavaScript
- Consider SSR/SSG for public-facing pages where SEO and initial load performance matter
- Use service workers and application shell caching for offline and repeat visit performance

## Details

### Basic structure

Consider this simple example for showing and updating the current time on a page using React.

```tsx
import { createRoot } from 'react-dom/client'
import { useEffect, useState } from 'react'

function Clock() {
  const [time, setTime] = useState(new Date())

  useEffect(() => {
    const id = setInterval(() => setTime(new Date()), 1000)
    return () => clearInterval(id)
  }, [])

  return (
    <div>
      <h1>Hello, world!</h1>
      <h2>It is {time.toLocaleTimeString()}.</h2>
    </div>
  )
}

createRoot(document.getElementById('root')!).render(<Clock />)
```

```html
<div id="root"></div>
```

The HTML consists of just a single root `<div>` tag. Content display and updates on the other hand are handled completely in JavaScript. There is no round trip to the server and rendered HTML is updated in-place. Here time could be replaced by any other real-time information like exchange rates or stock prices obtained from an API and displayed without refreshing the page or a round trip to the server.

### JavaScript bundles and Performance

As the complexity of the page increases to show images, display data from a data store and include event handling, the complexity and size of the JavaScript code required to render the page will also increase. CSR resulted in large JavaScript bundles which increased the FCP and TTI of the page.

As the size of bundle.js increases, the FCP and TTI are pushed forward. This implies that the user will see a blank screen for the entire duration between FP and FCP.

### Pros and Cons

With React most of the application logic is executed on the client and it interacts with the server through API calls to fetch or save data. Almost all of the UI is thus generated on the client. The entire web application is loaded on the first request. As the user navigates by clicking on links, no new request is generated to the server for rendering the pages. The code runs on the client to change the view/data.

CSR allows us to have a Single-Page Application that supports navigation without page refresh and provides a great user experience. As the data processed to change the view is limited, routing between pages is generally faster making the CSR application seem more responsive. CSR also allows developers to achieve a clear separation between client and server code.

Despite the great interactive experience that it provides, there are a few pitfalls to CSR:

1. **SEO considerations:** Most web crawlers can interpret server rendered websites in a straight-forward manner. Things get slightly complicated in the case of client-side rendering as large payloads and a waterfall of network requests (e.g for API responses) may result in meaningful content not being rendered fast enough for a crawler to index it. Crawlers may understand JavaScript but there are limitations. As such, some workarounds are required to make a client-rendered website SEO friendly.

2. **Performance**: With client-side rendering, the response time during interactions is greatly improved as there is no round trip to the server. However, for browsers to render content on client-side the first time, they have to wait for the JavaScript to load first and start processing. Thus users will experience some lag before the initial page loads. This may affect the user experience as the size of JS bundles get bigger and/or the client does not have sufficient processing power.

3. **Code Maintainability:** Some elements of code may get repeated across client and server (APIs) in different languages. In other cases, clean separation of business logic may not be possible. Examples of this could include validations and formatting logic for currency and date fields.

4. **Data Fetching**: With client-side rendering, data fetching is usually event-driven. The page could initially be loaded without any data. Data may be subsequently fetched on the occurrence of events like page-load or button-clicks using API calls. Depending on the size of data this could add to the load/interaction time of the application.

The importance of these considerations may be different across applications. Developers are often interested in finding SEO friendly solutions that can serve pages faster without compromising on the interaction time.

### Improving CSR performance

Since performance for CSR is inversely proportional to the size of the JavaScript bundle, the best thing we can do is structure our JavaScript code for optimal performance. Following is a list of pointers that could help:

- **Budgeting JavaScript**: Ensure that you have a reasonably tight JavaScript budget for your initial page loads. An initial bundle of < 100-170KB minified and gzipped is a good starting point. Code can then be loaded on-demand as features are needed.

- **Preloading**: This technique can be used to preload critical resources that would be required by the page, earlier in the page lifecycle. Critical resources may include JavaScript which can be preloaded by including the following directive in the `<head>` section of the HTML.

```html
<link rel="preload" as="script" href="critical.js" />
```

This informs the browser to start loading the `critical.js` file before the page rendering mechanism starts. The script will thus be available earlier and will not block the page rendering mechanism thereby improving the performance.

- **Lazy loading**: With lazy loading, you can identify resources that are non-critical and load these only when needed. Initial page load times can be improved using this approach as the size of resources loaded initially is reduced. For example, a chat widget component would generally not be needed immediately on page load and can be lazy loaded.

- **Code Splitting**: To avoid a large bundle of JavaScript code, you could start splitting your bundles. Code-Splitting is supported by bundlers like [Webpack](https://webpack.js.org/guides/code-splitting/) where it can be used to create multiple bundles that can be dynamically loaded at runtime. Code splitting also enables you to lazy load JavaScript resources.

- **Application shell caching with service workers:** This technique involves caching the application shell which is the minimal HTML, CSS, and JavaScript powering a user interface. Service workers can be used to cache the application shell offline. This can be useful in providing a native single-page app experience where the remaining content is loaded progressively as needed.

With these techniques, CSR can help to provide a faster Single-Page Application experience with a decent FCP and TTI.

## Source

- [patterns.dev/react/client-side-rendering](https://patterns.dev/react/client-side-rendering)

© patterns.dev · MIT · PatternsDev/skills

Similar skills

Everything for Frontend and UI →

From the same set46

presentational-container-pattern Teaches agents the presentational and container pattern to split data fetching from React UI. Useful when isolating state and API calls to simplify testing and component reuse. CX Codex +1 1,100installs react-composition-2026 A skill that pushes your agent away from boolean props and rigid component APIs toward compound components, explicit variants and children. CX Codex +1 1,100installs hooks-pattern A skill that teaches your agent React Hooks and helps pull repeated stateful logic into custom hooks. Useful when components start duplicating behaviour. CX Codex +1 1,100installs render-props-pattern A skill that walks through the render props pattern in React and tells you when a hook is the better call. Useful when rendering logic has to be shared across components. CX Codex +1 1,000installs hoc-pattern Teaches your AI assistant the Higher-Order Component pattern to share logic across React components. Useful for reusable auth, logging, or data fetching. CX Codex +1 1,000installs compound-pattern Teaches the agent the compound component pattern for shared implicit state. Useful for tabs, accordions and dropdowns whose parts must coordinate without explicit props. CX Codex +1 1,000installs react-server-components A skill that teaches React Server Components: which components belong on the server and where 'use client' goes. Useful in Next.js App Router. CX Codex +1 954installs progressive-hydration A skill that tells the agent how to split hydration of a server-rendered React app and defer JavaScript for non-critical sections. CX Codex +1 952installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor