react-router-framework-mode by remix-run/agent-skills
npx skills add https://github.com/remix-run/agent-skills --skill react-router-framework-mode框架模式是 React Router 的全栈开发体验,包含基于文件的路由、服务端、客户端和静态渲染策略、数据加载与变更,以及类型安全的路由模块 API。
app/routes.ts)loader 或 clientLoader 加载数据action 或 clientAction 处理变更<Link>、<NavLink>、<Form>、redirect 和 进行导航广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
useNavigatereact-router.config.ts)加载相关参考文档以获取特定 API/概念的详细指导:
| 参考文档 | 适用场景 |
|---|---|
references/routing.md | 配置路由、嵌套路由、动态片段 |
references/route-modules.md | 了解所有路由模块导出项 |
references/special-files.md | 自定义 root.tsx,添加全局导航/页脚、字体 |
references/data-loading.md | 使用加载器、流式传输、缓存加载数据 |
references/actions.md | 处理表单、变更、验证 |
references/navigation.md | 链接、编程式导航、重定向 |
references/pending-ui.md | 加载状态、乐观 UI |
references/error-handling.md | 错误边界、错误报告 |
references/rendering-strategies.md | SSR 与 SPA 与预渲染配置 |
references/middleware.md | 添加中间件(需要 v7.9.0+) |
references/sessions.md | Cookie 会话、身份验证、受保护路由 |
references/type-safety.md | 自动生成的路由类型、类型导入、类型安全 |
某些功能需要特定版本的 React Router。在实现前请务必验证:
npm list react-router
| 功能 | 最低版本 | 备注 |
|---|---|---|
| 中间件 | 7.9.0+ | 需要 v8_middleware 标志 |
| 核心框架功能 | 7.0.0+ | loaders、actions、Form 等 |
以下是最重要的模式。请加载相关参考文档以获取完整详情。
搜索表单 - 使用 <Form method="get">,不要使用 onSubmit 配合 setSearchParams:
// ✅ 正确
<Form method="get">
<input name="q" />
</Form>
// ❌ 错误 - 不要手动处理搜索参数
<form onSubmit={(e) => { e.preventDefault(); setSearchParams(...) }}>
内联变更 - 使用 useFetcher,不要使用 <Form>(会导致页面导航):
const fetcher = useFetcher();
const optimistic = fetcher.formData?.get("favorite") === "true" ?? isFavorite;
<fetcher.Form method="post" action={`/favorites/${id}`}>
<button>{optimistic ? "★" : "☆"}</button>
</fetcher.Form>;
完整模式请参见 references/actions.md。
全局 UI 应放在 root.tsx 中 - 不要为导航/页脚创建单独的布局文件:
// app/root.tsx - 在此处添加导航、页脚、提供者
export default function App() {
return (
<div>
<nav>...</nav>
<Outlet />
<footer>...</footer>
</div>
);
}
对于特定部分的布局,请使用嵌套路由。参见 references/routing.md。
meta 使用 loaderData,而不是已弃用的 data:
// ✅ 正确
export function meta({ loaderData }: Route.MetaArgs) { ... }
// ❌ 错误 - `data` 已弃用
export function meta({ data }: Route.MetaArgs) { ... }
所有导出项请参见 references/route-modules.md。
如果这些参考文档未涵盖任何与 React Router 相关的内容,您可以搜索官方文档:
每周安装量
1.2K
代码仓库
GitHub 星标数
104
首次出现
2026年1月29日
安全审计
安装于
opencode1.1K
codex1.1K
github-copilot1.0K
gemini-cli1.0K
amp967
kimi-cli963
Framework mode is React Router's full-stack development experience with file-based routing, server-side, client-side, and static rendering strategies, data loading and mutations, and type-safe route module API.
app/routes.ts)loader or clientLoaderaction or clientAction<Link>, <NavLink>, <Form>, redirect, and useNavigatereact-router.config.ts)Load the relevant reference for detailed guidance on the specific API/concept:
| Reference | Use When |
|---|---|
references/routing.md | Configuring routes, nested routes, dynamic segments |
references/route-modules.md | Understanding all route module exports |
references/special-files.md | Customizing root.tsx, adding global nav/footer, fonts |
references/data-loading.md | Loading data with loaders, streaming, caching |
references/actions.md | Handling forms, mutations, validation |
references/navigation.md |
Some features require specific React Router versions. Always verify before implementing:
npm list react-router
| Feature | Minimum Version | Notes |
|---|---|---|
| Middleware | 7.9.0+ | Requires v8_middleware flag |
| Core framework features | 7.0.0+ | loaders, actions, Form, etc. |
These are the most important patterns to follow. Load the relevant reference for full details.
Search forms - use <Form method="get">, NOT onSubmit with setSearchParams:
// ✅ Correct
<Form method="get">
<input name="q" />
</Form>
// ❌ Wrong - don't manually handle search params
<form onSubmit={(e) => { e.preventDefault(); setSearchParams(...) }}>
Inline mutations - use useFetcher, NOT <Form> (which causes page navigation):
const fetcher = useFetcher();
const optimistic = fetcher.formData?.get("favorite") === "true" ?? isFavorite;
<fetcher.Form method="post" action={`/favorites/${id}`}>
<button>{optimistic ? "★" : "☆"}</button>
</fetcher.Form>;
See references/actions.md for complete patterns.
Global UI belongs inroot.tsx - don't create separate layout files for nav/footer:
// app/root.tsx - add navigation, footer, providers here
export default function App() {
return (
<div>
<nav>...</nav>
<Outlet />
<footer>...</footer>
</div>
);
}
Use nested routes for section-specific layouts. See references/routing.md.
meta uses loaderData, not deprecated data:
// ✅ Correct
export function meta({ loaderData }: Route.MetaArgs) { ... }
// ❌ Wrong - `data` is deprecated
export function meta({ data }: Route.MetaArgs) { ... }
See references/route-modules.md for all exports.
If anything related to React Router is not covered in these references, you can search the official documentation:
Weekly Installs
1.2K
Repository
GitHub Stars
104
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode1.1K
codex1.1K
github-copilot1.0K
gemini-cli1.0K
amp967
kimi-cli963
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
| Links, programmatic navigation, redirects |
references/pending-ui.md | Loading states, optimistic UI |
references/error-handling.md | Error boundaries, error reporting |
references/rendering-strategies.md | SSR vs SPA vs pre-rendering configuration |
references/middleware.md | Adding middleware (requires v7.9.0+) |
references/sessions.md | Cookie sessions, authentication, protected routes |
references/type-safety.md | Auto-generated route types, type imports, type safety |