Skip to main content
rule CX Codex

rendering-resource-hints — Claude Code rule: what it does

The rendering-resource-hints rule tells the agent when to call React DOM's resource-hint functions inside React components. It targets server components, letting the browser start fetching assets before the client even has the HTML.

MIT ★ 1,216 updated 2026-10-24

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settings
Open on GitHub

What rendering-resource-hints does

The rule walks through six React DOM functions — prefetchDNS, preconnect, preload, preloadModule, preinit, preinitModule — and maps each to a use case. prefetchDNS resolves a domain name ahead of time, while preconnect opens the full connection (DNS, TCP, TLS) for an API or CDN the page will hit right away. preload and preinit fetch one specific file such as a font, stylesheet, script or image; preinit also executes it immediately, preload just warms the cache.

For code-split bundles there's preloadModule and preinitModule: the first suits a route the user is likely to open next, triggered for instance on link hover, the second covers modules that need to run straight away. The rule's sample code attaches preconnect to a third-party API inside an App component, loads a font plus a critical stylesheet inside a RootLayout, and warms a dashboard module when the nav link gets a mouse hover.

Everything runs through the react-dom package and only makes sense inside React server components, since that's where hints can reach the browser before the markup itself arrives.

What it helps with

  • wire up preconnect and prefetchDNS for third-party APIs
  • load critical fonts and stylesheets with preload
  • force an early stylesheet fetch and run via preinit
  • speed up code-split route transitions with preloadModule
  • pick the right resource-hint API from the rule's comparison table

Example prompts for the agent

  • Add preconnect to api.example.com inside the App component
  • Set up a font load in RootLayout with the font/woff2 type
  • Warm the dashboard route module on nav link hover using preloadModule

How to install rendering-resource-hints

1Plugin marketplace

/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settings

2Manually: put the files in place

.claude/rules/rendering-resource-hints.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about rendering-resource-hints

How do I install rendering-resource-hints in Claude Code?

Run /plugin marketplace add fcakyon/claude-codex-settings, then /plugin install react-skills@claude-settings.

What does rendering-resource-hints do?

It tells the agent when to insert prefetchDNS, preconnect, preload, preloadModule, preinit and preinitModule calls from react-dom so the browser fetches key assets earlier.

Which platforms support this rule?

Claude Code reads it from .claude/rules/rendering-resource-hints.md; Cursor, GitHub Copilot, Windsurf and Cline each get their own file format for the same rule.

Source text

rendering-resource-hints.md · MIT
---
title: Use React DOM Resource Hints
impact: HIGH
impactDescription: reduces load time for critical resources
tags: rendering, preload, preconnect, prefetch, resource-hints
---

## Use React DOM Resource Hints

**Impact: HIGH (reduces load time for critical resources)**

React DOM provides APIs to hint the browser about resources it will need. These are especially useful in server components to start loading resources before the client even receives the HTML.

- **`prefetchDNS(href)`**: Resolve DNS for a domain you expect to connect to
- **`preconnect(href)`**: Establish connection (DNS + TCP + TLS) to a server
- **`preload(href, options)`**: Fetch a resource (stylesheet, font, script, image) you'll use soon
- **`preloadModule(href)`**: Fetch an ES module you'll use soon
- **`preinit(href, options)`**: Fetch and evaluate a stylesheet or script
- **`preinitModule(href)`**: Fetch and evaluate an ES module

**Example (preconnect to third-party APIs):**

```tsx
import { preconnect, prefetchDNS } from 'react-dom'

export default function App() {
  prefetchDNS('https://analytics.example.com')
  preconnect('https://api.example.com')

  return <main>{/* content */}</main>
}
```

**Example (preload critical fonts and styles):**

```tsx
import { preload, preinit } from 'react-dom'

export default function RootLayout({ children }) {
  // Preload font file
  preload('/fonts/inter.woff2', { as: 'font', type: 'font/woff2', crossOrigin: 'anonymous' })

  // Fetch and apply critical stylesheet immediately
  preinit('/styles/critical.css', { as: 'style' })

  return (
    <html>
      <body>{children}</body>
    </html>
  )
}
```

**Example (preload modules for code-split routes):**

```tsx
import { preloadModule, preinitModule } from 'react-dom'

function Navigation() {
  const preloadDashboard = () => {
    preloadModule('/dashboard.js', { as: 'script' })
  }

  return (
    <nav>
      <a href="/dashboard" onMouseEnter={preloadDashboard}>
        Dashboard
      </a>
    </nav>
  )
}
```

**When to use each:**

| API | Use case |
|-----|----------|
| `prefetchDNS` | Third-party domains you'll connect to later |
| `preconnect` | APIs or CDNs you'll fetch from immediately |
| `preload` | Critical resources needed for current page |
| `preloadModule` | JS modules for likely next navigation |
| `preinit` | Stylesheets/scripts that must execute early |
| `preinitModule` | ES modules that must execute early |

Reference: [React DOM Resource Preloading APIs](https://react.dev/reference/react-dom#resource-preloading-apis)

© fcakyon · MIT · fcakyon/claude-codex-settings

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set113

The whole set →
setup setup configures Tavily MCP server credentials inside Claude Code and saves them to the plugin configuration. CX Codex +1 ★ 1,216repo stars bundle-analyzable-paths The bundle-analyzable-paths rule recommends making import and file paths statically analyzable. That keeps bundlers from treating a broad set of files as reachable. CX Codex +1 ★ 1,216repo stars list-performance-item-expensive The list-performance-item-expensive rule bans heavy list rows: data queries, extra hooks and React Context reads inside renderItem. CX Codex +1 ★ 1,216repo stars ui-image-gallery ui-image-gallery directs AI assistants to build image galleries using @nandorojo/galeria instead of custom modal popups. CX Codex +1 ★ 1,216repo stars animation-gesture-detector-press animation-gesture-detector-press is a React Native rule that keeps press animations on the UI thread, for buttons that scale or fade while pressed. CX Codex +1 ★ 1,216repo stars commit-staged commit-staged automates commit creation: checks staged diffs, runs /simplify on code edits, and writes conventional commits using session rationale. CX Codex +1 ★ 1,216repo stars shell-and-workflows The shell-and-workflows rule documents Docker commands for the project and explains where to run frontend and backend tests. Use it when managing services or checking a change. CX Codex +1 ★ 1,216repo stars js-request-idle-callback js-request-idle-callback — a rule that moves analytics, state saving and prefetching into idle browser time so the interface stops stuttering on every click. CX Codex +1 ★ 1,216repo stars

Project sponsors

Companies that keep this analytics open