Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# @lazarv/react-server — Contributor Guide

This is the monorepo for `@lazarv/react-server`, an open React Server Components runtime built on the Vite Environment API.

## Monorepo Structure

```
packages/
react-server/ # Core runtime (@lazarv/react-server)
rsc/ # RSC serialization (@lazarv/rsc)
create-react-server/ # Project scaffold CLI (@lazarv/create-react-server)
docs/ # Documentation site (react-server.dev), built with react-server itself
examples/ # 33+ example applications
test/ # Integration tests (Vitest + Playwright)
```

Package manager: **pnpm** (enforced via `preinstall` check).

## Key Commands

```sh
# Install dependencies
pnpm install

# Run docs dev server
pnpm docs

# Build docs
pnpm docs-build

# Run all tests (from root)
pnpm test

# Run tests from test/ directory
cd test
pnpm test-dev-base # Dev mode tests (excludes app tests)
pnpm test-dev-apps # Dev mode app tests
pnpm test-build-start # Build + start mode tests
pnpm test-dev # All dev mode tests

# Format code
pnpm format # Uses oxfmt

# Lint
pnpm lint # Uses oxlint
```

## Coding Conventions

- **ESM only** — all packages use `"type": "module"`
- **No TypeScript in core packages** — pure JavaScript with `.d.ts` type definitions
- **JSX file extensions** — use `.jsx` for React components
- **Config/server files** — use `.mjs` extension
- **Commit messages** — conventional commits (`feat:`, `fix:`, `docs:`, `chore:`, `perf:`, `refactor:`, `test:`, `build:`, `ci:`)
- Format: `type(scope): subject` (e.g., `feat(router): add catch-all routes`)
- Imperative, present tense, no capitalization, no period at end
- Enforced by commitlint

## Docs Site

- Built with `@lazarv/react-server` itself (dogfooding)
- MDX pages in `docs/src/pages/en/(pages)/`
- Bilingual: English (`en/`) and Japanese (`ja/`)
- Deployed to Cloudflare
- All pages exported as `.md` for AI consumption
- Config: `docs/react-server.config.mjs`

## Test Infrastructure

- **Vitest** for test runner
- **Playwright (Chromium)** for browser-based integration tests
- Two configs: `vitest.config.mjs` (dev mode) and `vitest.config.build.mjs` (build+start mode)
- Test fixtures in `test/fixtures/`
- Test specs in `test/__test__/`

## Package Exports

The main `@lazarv/react-server` package has many subpath exports:
`/client`, `/server`, `/config`, `/router`, `/navigation`, `/error-boundary`, `/remote`, `/worker`, `/mcp`, `/cache`, and more. Check `packages/react-server/package.json` exports field for the full list.
102 changes: 102 additions & 0 deletions docs/src/pages/en/(pages)/integrations/claude-code.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Claude Code
category: Integrations
order: 7
---

import Link from "../../../../components/Link.jsx";

# Claude Code

[Claude Code](https://docs.anthropic.com/en/docs/claude-code) is Anthropic's official CLI tool for AI-assisted coding. `@lazarv/react-server` provides an installable Claude Code skill that gives Claude deep knowledge of the runtime's APIs, conventions, and patterns — so you can build react-server applications using agentic coding.

<Link name="install-skill">
## Install the skill
</Link>

Install the skill into your project using `npx skills`:

```sh
npx skills add lazarv/react-server
```

This installs the `react-server` skill from the repository's `skills/` directory into your project's `.claude/skills/` folder. Once installed, the `/react-server` slash command becomes available in Claude Code.

To install it globally so it's available across all your projects:

```sh
npx skills add lazarv/react-server --global
```

<Link name="usage">
## Usage
</Link>

Start Claude Code in your project directory and use the `/react-server` slash command to give Claude the full context of the runtime. You can pass additional instructions as arguments:

```sh
# General react-server context
/react-server

# With specific instructions
/react-server add a new /api/users route that returns a list of users from the database

# Scaffold a new feature
/react-server create a live component that streams stock prices
```

The skill loads all core patterns, file-system router conventions, use directives, import paths, and component patterns into Claude's context automatically.

<Link name="docs-as-context">
## Using docs as context
</Link>

Every page on this documentation site is also available as plain markdown. You can paste these URLs directly in a Claude Code conversation for detailed, up-to-date reference on specific features:

| Topic | URL |
|---|---|
| Server Components | `https://react-server.dev/guide/server-components.md` |
| Client Components | `https://react-server.dev/guide/client-components.md` |
| Server Functions | `https://react-server.dev/guide/server-functions.md` |
| File Router | `https://react-server.dev/router/file-router.md` |
| Configuration | `https://react-server.dev/features/configuration.md` |
| Caching | `https://react-server.dev/features/caching.md` |
| HTTP | `https://react-server.dev/features/http.md` |
| Live Components | `https://react-server.dev/features/live-components.md` |
| Workers | `https://react-server.dev/features/workers.md` |
| MCP | `https://react-server.dev/features/mcp.md` |
| Error Handling | `https://react-server.dev/features/error-handling.md` |
| API Routes | `https://react-server.dev/router/api-routes.md` |
| Middlewares | `https://react-server.dev/router/middlewares.md` |
| Outlets | `https://react-server.dev/router/outlets.md` |
| CLI | `https://react-server.dev/features/cli.md` |

<Link name="whats-included">
## What's included
</Link>

The skill provides Claude Code with comprehensive knowledge of:

- **Use directives** — `"use client"`, `"use server"`, `"use live"`, `"use worker"`, `"use cache"`, `"use dynamic"`, `"use static"` and their semantics including inline (lexically scoped) usage
- **File-system router** — page, layout, dynamic route, catch-all, outlet, middleware, API route, and MCP endpoint conventions
- **Import paths** — all `@lazarv/react-server/*` subpath exports and their key APIs
- **Component patterns** — server components, client components, server functions, live components, workers, and lexically scoped RSC with arbitrary server/client nesting
- **HTTP hooks** — `useUrl`, `usePathname`, `headers`, `cookie`, `redirect`, `rewrite`, `status`, `after`, and more
- **Caching** — response cache, in-memory cache, cache directive with TTL/tags/profiles, revalidation
- **Configuration** — `defineConfig`, extension configs, mode-specific configs, JSON schema, env variables
- **Navigation** — `Link`, `Refresh`, `ReactServerComponent`, programmatic navigation via `useClient`
- **Error handling** — `ErrorBoundary` component and file-router error/loading conventions
- **Deployment** — all 11 adapter targets (Vercel, Netlify, Cloudflare, AWS, Azure, Bun, Deno, Docker, Firebase, etc.)
- **Advanced features** — micro-frontends with `RemoteComponent`, MCP server with `createServer`/`createTool`/`createResource`/`createPrompt`, MDX support

<Link name="updating">
## Updating the skill
</Link>

To update to the latest version of the skill:

```sh
npx skills add lazarv/react-server
```

The skill is maintained alongside the documentation and updated with each release.
102 changes: 102 additions & 0 deletions docs/src/pages/ja/(pages)/integrations/claude-code.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Claude Code
category: Integrations
order: 7
---

import Link from "../../../../components/Link.jsx";

# Claude Code

[Claude Code](https://docs.anthropic.com/en/docs/claude-code)はAnthropicが提供するAIコーディング支援の公式CLIツールです。`@lazarv/react-server`はインストール可能なClaude Codeスキルを提供しており、ランタイムのAPI、規約、パターンに関する深い知識をClaudeに与えることで、エージェントコーディングによるreact-serverアプリケーションの構築を支援します。

<Link name="install-skill">
## スキルのインストール
</Link>

`npx skills`を使用してプロジェクトにスキルをインストールします:

```sh
npx skills add lazarv/react-server
```

これにより、リポジトリの`skills/`ディレクトリから`react-server`スキルがプロジェクトの`.claude/skills/`フォルダにインストールされます。インストール後、Claude Codeで`/react-server`スラッシュコマンドが利用可能になります。

すべてのプロジェクトで利用できるようにグローバルにインストールする場合:

```sh
npx skills add lazarv/react-server --global
```

<Link name="usage">
## 使い方
</Link>

プロジェクトディレクトリでClaude Codeを起動し、`/react-server`スラッシュコマンドを使用してClaudeにランタイムの完全なコンテキストを提供します。引数として追加の指示を渡すことができます:

```sh
# react-serverの一般的なコンテキスト
/react-server

# 具体的な指示を付けて
/react-server データベースからユーザー一覧を返す /api/users ルートを追加して

# 新機能のスキャフォールド
/react-server 株価をストリーミングするライブコンポーネントを作成して
```

スキルはすべてのコアパターン、ファイルシステムルーターの規約、useディレクティブ、インポートパス、コンポーネントパターンをClaudeのコンテキストに自動的に読み込みます。

<Link name="docs-as-context">
## ドキュメントをコンテキストとして使用
</Link>

このドキュメントサイトのすべてのページは、プレーンマークダウンとしても利用できます。特定の機能に関する詳細で最新のリファレンスとして、これらのURLをClaude Codeの会話に直接貼り付けることができます:

| トピック | URL |
|---|---|
| サーバーコンポーネント | `https://react-server.dev/guide/server-components.md` |
| クライアントコンポーネント | `https://react-server.dev/guide/client-components.md` |
| サーバー関数 | `https://react-server.dev/guide/server-functions.md` |
| ファイルルーター | `https://react-server.dev/router/file-router.md` |
| 設定 | `https://react-server.dev/features/configuration.md` |
| キャッシュ | `https://react-server.dev/features/caching.md` |
| HTTP | `https://react-server.dev/features/http.md` |
| ライブコンポーネント | `https://react-server.dev/features/live-components.md` |
| ワーカー | `https://react-server.dev/features/workers.md` |
| MCP | `https://react-server.dev/features/mcp.md` |
| エラーハンドリング | `https://react-server.dev/features/error-handling.md` |
| APIルート | `https://react-server.dev/router/api-routes.md` |
| ミドルウェア | `https://react-server.dev/router/middlewares.md` |
| アウトレット | `https://react-server.dev/router/outlets.md` |
| CLI | `https://react-server.dev/features/cli.md` |

<Link name="whats-included">
## 含まれる内容
</Link>

このスキルはClaude Codeに以下の包括的な知識を提供します:

- **useディレクティブ** — `"use client"`、`"use server"`、`"use live"`、`"use worker"`、`"use cache"`、`"use dynamic"`、`"use static"`のセマンティクスとインライン(レキシカルスコープ)での使用方法
- **ファイルシステムルーター** — ページ、レイアウト、動的ルート、キャッチオール、アウトレット、ミドルウェア、APIルート、MCPエンドポイントの規約
- **インポートパス** — すべての`@lazarv/react-server/*`サブパスエクスポートとその主要API
- **コンポーネントパターン** — サーバーコンポーネント、クライアントコンポーネント、サーバー関数、ライブコンポーネント、ワーカー、およびサーバー/クライアントの任意のネストが可能なレキシカルスコープRSC
- **HTTPフック** — `useUrl`、`usePathname`、`headers`、`cookie`、`redirect`、`rewrite`、`status`、`after`など
- **キャッシュ** — レスポンスキャッシュ、インメモリキャッシュ、TTL/タグ/プロファイル付きキャッシュディレクティブ、再検証
- **設定** — `defineConfig`、拡張設定、モード別設定、JSONスキーマ、環境変数
- **ナビゲーション** — `Link`、`Refresh`、`ReactServerComponent`、`useClient`によるプログラムナビゲーション
- **エラーハンドリング** — `ErrorBoundary`コンポーネントとファイルルーターのerror/loading規約
- **デプロイ** — 全11アダプターターゲット(Vercel、Netlify、Cloudflare、AWS、Azure、Bun、Deno、Docker、Firebaseなど)
- **高度な機能** — `RemoteComponent`によるマイクロフロントエンド、`createServer`/`createTool`/`createResource`/`createPrompt`によるMCPサーバー、MDXサポート

<Link name="updating">
## スキルの更新
</Link>

最新バージョンのスキルに更新するには:

```sh
npx skills add lazarv/react-server
```

スキルはドキュメントと同時にメンテナンスされ、各リリースで更新されます。
3 changes: 3 additions & 0 deletions packages/react-server/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export async function loadConfig(initialConfig, options = {}) {
config[root]
);

// Remove $schema (JSON Schema reference for IDE validation, not a runtime option)
delete config[CONFIG_ROOT].$schema;

for (const key of configKeys) {
if (key === CONFIG_ROOT || key === root) continue;
merge(
Expand Down
3 changes: 3 additions & 0 deletions packages/react-server/config/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ function validateObject(config, schema, prefix = "") {
// Skip symbol keys (like CONFIG_ROOT, CONFIG_PARENT)
if (typeof key === "symbol") continue;

// Skip $schema (JSON Schema reference for IDE validation)
if (key === "$schema") continue;

const path = prefix ? `${prefix}.${key}` : key;
const validator = schema[key];

Expand Down
Loading
Loading