Docs Rsc Sandpack logo

Docs Rsc Sandpack

OrganizationPopular
reactjs
docs-rsc-sandpack

Use when adding interactive RSC (React Server Components) code examples to React docs using <SandpackRSC>, or when modifying the RSC sandpack infrastructure.

Overview

Publisherreactjs
Repositoryreact.dev
Skill namedocs-rsc-sandpack
Stars
11.8K
Forks
8K
Bundled files
Instructions only
LicenseCC-BY-4.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by reactjs on GitHub. Read the source before you install it.

Installation

Install the Docs Rsc Sandpack AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/reactjs/react.dev/tree/main/.claude/skills/docs-rsc-sandpack
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/reactjs/react.dev.git /tmp/react.dev
mkdir -p .claude/skills
cp -r /tmp/react.dev/.claude/skills/docs-rsc-sandpack .claude/skills/docs-rsc-sandpack
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Docs Rsc Sandpack in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Docs Rsc Sandpack on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Docs Rsc Sandpack is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

RSC Sandpack Patterns

For general Sandpack conventions (code style, naming, file naming, line highlighting, hidden files, CSS guidelines), see /docs-sandpack. This skill covers only RSC-specific patterns.

Quick Start Template

Minimal single-file <SandpackRSC> example:

mdx
<SandpackRSC>

` ` `js src/App.js
export default function App() {
  return <h1>Hello from a Server Component!</h1>;
}
` ` `

</SandpackRSC>

How It Differs from <Sandpack>

Feature<Sandpack><SandpackRSC>
Execution modelAll code runs in iframeServer code runs in Web Worker, client code in iframe
'use client' directiveIgnored (everything is client)Required to mark client components
'use server' directiveNot supportedMarks Server Functions callable from client
async componentsNot supportedSupported (server components can be async)
External dependenciesSupported via package.jsonNot supported (only React + react-dom)
Entry pointApp.js with export defaultsrc/App.js with export default
Component tag<Sandpack><SandpackRSC>

File Directives

Files are classified by the directive at the top of the file:

DirectiveWhere it runsRules
(none)Web Worker (server)Default. Can be async. Can import other server files. Cannot use hooks, event handlers, or browser APIs.
'use client'Sandpack iframe (browser)Must be first statement. Can use hooks, event handlers, browser APIs. Cannot be async. Cannot import server files.
'use server'Web Worker (server)Marks Server Functions. Can be module-level (all exports are actions) or function-level. Callable from client via props or form action.

Common Patterns

1. Server + Client Components

mdx
<SandpackRSC>

` ` `js src/App.js
import Counter from './Counter';

export default function App() {
  return (
    <div>
      <h1>Server-rendered heading</h1>
      <Counter />
    </div>
  );
}
` ` `

` ` `js src/Counter.js
'use client';

import { useState } from 'react';

export default function Counter() {
  const [count, setCount] = useState(0);
  return (
    <button onClick={() => setCount(count + 1)}>
      Count: {count}
    </button>
  );
}
` ` `

</SandpackRSC>

2. Async Server Component with Suspense

mdx
<SandpackRSC>

` ` `js src/App.js
import { Suspense } from 'react';
import Albums from './Albums';

export default function App() {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      <Albums />
    </Suspense>
  );
}
` ` `

` ` `js src/Albums.js
async function fetchAlbums() {
  await new Promise(resolve => setTimeout(resolve, 1000));
  return ['Abbey Road', 'Let It Be', 'Revolver'];
}

export default async function Albums() {
  const albums = await fetchAlbums();
  return (
    <ul>
      {albums.map(album => (
        <li key={album}>{album}</li>
      ))}
    </ul>
  );
}
` ` `

</SandpackRSC>

3. Server Functions (Actions)

mdx
<SandpackRSC>

` ` `js src/App.js
import { addLike, getLikeCount } from './actions';
import LikeButton from './LikeButton';

export default async function App() {
  const count = await getLikeCount();
  return (
    <div>
      <p>Likes: {count}</p>
      <LikeButton addLike={addLike} />
    </div>
  );
}
` ` `

` ` `js src/actions.js
'use server';

let count = 0;

export async function addLike() {
  count++;
}

export async function getLikeCount() {
  return count;
}
` ` `

` ` `js src/LikeButton.js
'use client';

export default function LikeButton({ addLike }) {
  return (
    <form action={addLike}>
      <button type="submit">Like</button>
    </form>
  );
}
` ` `

</SandpackRSC>

File Structure Requirements

Entry Point

  • src/App.js is required as the main entry point
  • Must have export default (function component)
  • Case-insensitive fallback: src/app.js also works

Auto-Injected Infrastructure Files

These files are automatically injected by sandpack-rsc-setup.ts and should never be included in MDX:

FilePurpose
/src/index.jsBootstraps the RSC pipeline
/src/rsc-client.jsClient bridge — creates Worker, consumes Flight stream
/src/rsc-server.jsWraps pre-bundled worker runtime as ES module
/node_modules/__webpack_shim__/index.jsMinimal webpack compatibility layer
/node_modules/__rsdw_client__/index.jsreact-server-dom-webpack/client as local dependency

No External Dependencies

<SandpackRSC> does not support external npm packages. Only react and react-dom are available. Do not include package.json in RSC examples.


Architecture Reference

Three-Layer Architecture

react.dev page (Next.js)
  ┌─────────────────────────────────────────┐
  │  <SandpackRSC>                          │
  │  ┌─────────┐  ┌──────────────────────┐  │
  │  │ Editor  │  │ Preview (iframe)     │  │
  │  │ App.js  │  │ Client React app     │  │
  │  │ (edit)  │  │ consumes Flight      │  │
  │  │         │  │ stream from Worker   │  │
  │  └─────────┘  └──────────┬───────────┘  │
  └───────────────────────────┼─────────────┘
                              │ postMessage
  ┌───────────────────────────▼─────────────┐
  │  Web Worker (Blob URL)                  │
  │  - React server build (pre-bundled)     │
  │  - react-server-dom-webpack/server      │
  │  - webpack shim                         │
  │  - User server code (Sucrase → CJS)    │
  └─────────────────────────────────────────┘

Key Source Files

FilePurpose
src/components/MDX/Sandpack/sandpack-rsc/RscFileBridge.tsxMonitors Sandpack; posts raw files to iframe
src/components/MDX/Sandpack/SandpackRSCRoot.tsxSandpackProvider setup, custom bundler URL, UI layout
src/components/MDX/Sandpack/templateRSC.tsRSC template files
.../sandbox-code/src/__react_refresh_init__.jsReact Refresh shim
.../sandbox-code/src/rsc-server.jsWorker runtime: module system, Sucrase compilation, renderToReadableStream()
.../sandbox-code/src/rsc-client.source.jsClient bridge: Worker creation, file classification, Flight stream consumption
.../sandbox-code/src/webpack-shim.jsMinimal __webpack_require__ / __webpack_module_cache__ shim
.../sandbox-code/src/worker-bundle.dist.jsPre-bundled IIFE (generated): React server + RSDW/server + Sucrase
scripts/buildRscWorker.mjsesbuild script: bundles rsc-server.js into worker-bundle.dist.js

Build System

Rebuilding the Worker Bundle

After modifying rsc-server.js or webpack-shim.js:

bash
node scripts/buildRscWorker.mjs

This runs esbuild with:

  • format: 'iife', platform: 'browser'
  • conditions: ['react-server', 'browser'] (activates React server export conditions)
  • minify: true
  • Prepends webpack-shim.js to the output

Raw-Loader Configuration

In templateRSC.js files are loaded as raw strings with the !raw-loader.

The strings are necessary to provide to Sandpack as local files (skips Sandpack bundling).

Development Commands

bash
node scripts/buildRscWorker.mjs   # Rebuild worker bundle after source changes
yarn dev                           # Start dev server to test examples

Frequently asked questions

What does the Docs Rsc Sandpack AI skill do?

Use when adding interactive RSC (React Server Components) code examples to React docs using <SandpackRSC>, or when modifying the RSC sandpack infrastructure.

Why use Docs Rsc Sandpack on TypingMind?

Because you install it once and use it with any model. Docs Rsc Sandpack is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Docs Rsc Sandpack in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/reactjs/react.dev/tree/main/.claude/skills/docs-rsc-sandpack. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Docs Rsc Sandpack?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Docs Rsc Sandpack?

As many as you like. As long as a model supports skills, you can use Docs Rsc Sandpack with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Docs Rsc Sandpack AI skill free?

Yes. It is published on GitHub by reactjs under the CC-BY-4.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇