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
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat 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
preconnectandprefetchDNSfor 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-settings2Manually: put the files in place
.claude/rules/rendering-resource-hints.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/rendering-resource-hints.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rendering-resource-hints.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rendering-resource-hints.mdManually: put the files in place
.clinerules/rendering-resource-hints.mdStep 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