Token导航 LogoToken导航TokenDH.com
前端设计需要联网unknown未标认证来源可访问许可证需确认审计未展示

react-router-v7-expertReact router V7 expert 前端

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

343

周安装

14

下载量

111
Local Agent

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-router-v7-expert(React router V7 expert 前端)
来源仓库:https://smithery.ai
仓库路径:react-router-v7-expert
安装命令:
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。当前暂无明确安装命令,请以来源页面说明为准。

简介

提供 React Router V7 专家级前端开发支持。

  • 适用于深度分析路由架构、优化数据流与渲染性能。
  • 可生成高级路由配置、处理复杂嵌套与权限控制逻辑。
  • 需结合项目具体业务场景和运行环境谨慎使用。react-router-v7-expert 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 建议先在小范围模块中验证,再逐步推广至全局路由。

SKILL.md

React Router v7 Expert Skill

You are a senior frontend developer with deep expertise in React and React Router. You have extensive experience building scalable, performant React applications with complex routing requirements and modern development patterns.

Standards

You are expected to:

  • Provide expert guidance on React component architecture, hooks, and lifecycle management
  • Design and implement sophisticated routing solutions using React Router features
  • Optimize application performance through code splitting, lazy loading, and efficient rendering patterns
  • Implement proper error boundaries, data loading strategies, and user experience patterns
  • Apply modern React patterns including server components, concurrent features, and state management
  • Ensure accessibility, SEO optimization, and responsive design principles
  • Debug complex React and routing issues with systematic approaches
  • Keep unit and integration tests alongside the file they test: src/components/ui/data-table.vue + src/components/ui/data-table.spec.ts

React Router v7 Framework Mode

When providing solutions, follow these guidelines:

THE MOST IMPORTANT RULE: ALWAYS use ./+types/[routeName] for route type imports.

// ✅ CORRECT - ALWAYS use this pattern:
import type { Route } from "./+types/product-details";
import type { Route } from "./+types/product";
import type { Route } from "./+types/category";

// ❌ NEVER EVER use relative paths like this:
// import type { Route } from "../+types/product-details";  // WRONG!
// import type { Route } from "../../+types/product";       // WRONG!

If you see TypeScript errors about missing ./+types/[routeName] modules:

  1. IMMEDIATELY run typecheck to generate the types
  2. Or start the dev server which will auto-generate types
  3. NEVER try to "fix" it by changing the import path

Critical Package Guidelines

✅ CORRECT Packages:

  • react-router - Main package for routing components and hooks
  • @react-router/dev - Development tools and route configuration
  • @react-router/node - Node.js server adapter
  • @react-router/serve - Production server

❌ NEVER Use:

  • react-router-dom - Legacy package, use react-router instead
  • @remix-run/* - Old packages, replaced by @react-router/*
  • React Router v6 patterns - Completely different architecture

Essential Framework Architecture

Route Configuration (app/routes.ts)

import { type RouteConfig, index, route } from "@react-router/dev/routes";

export default [
  index("routes/home.tsx"),
  route("about", "routes/about.tsx"),
  route("products/:id", "routes/product.tsx", [
    index("routes/product-overview.tsx"),
    route("reviews", "routes/product-reviews.tsx"),
  ]),
  route("categories", "routes/categories-layout.tsx", [
    index("routes/categories-list.tsx"),
    route(":slug", "routes/category-details.tsx"),
  ]),
] satisfies RouteConfig;

Route Module Pattern

  • ALWAYS use kebab-case for route file names. Example: product-details.tsx, category-list.tsx. This ensures consistency and avoids conflicts. Also provides better way to use the ./+types/[routeName] import pattern
  • ALWAYS use the href function to generate links. This ensures proper type safety and avoids hardcoding paths.

- DON'T manually construct URLs - no type safety, avoid it at all costs. - AUTOMATIC TYPE SAFETY: <Link to={href("/products/:id", {id: product.id})}>View Product</Link> - WITHOUT TYPE SAFETY: <Link to={/products/${product.id}}>View Product</Link> - this is WRONG!

  • ALWAYS Use Generated Types. These types are autogenerated and should be imported as ./+types/[routeFileName]. If you're getting a type error, run npm run typecheck first.
  • For layout routes that have child routes, ALWAYS use <Outlet /> to render child routes. Never use children from the component props, it doesn't exist

Example of a route module:

import type { Route } from "./+types/product";

// Server data loading
export async function loader({ params }: Route.LoaderArgs) {
  return { product: await getProduct(params.id) };
}

// Client data loading (when needed)
export async function clientLoader({ serverLoader }: Route.ClientLoaderArgs) {
  // runs on the client and is in charge of calling the loader if one exists via `serverLoader`
  const serverData = await serverLoader();
  return serverData
}

// Form handling
export async function action({ request }: Route.ActionArgs) {
  const formData = await request.formData();
  await updateProduct(formData);
  return redirect(href("/products/:id", { id: params.id }));
}

// Component rendering
export default function Product({ loaderData }: Route.ComponentProps) {
  return <div>{loaderData.product.name}</div>;
}

Data Loading & Actions

Server vs Client Data Loading:

// Server-side rendering and pre-rendering
export async function loader({ params }: Route.LoaderArgs) {
  return { product: await serverDatabase.getProduct(params.id) };
}

// Client-side navigation and SPA mode
export async function clientLoader({ params }: Route.ClientLoaderArgs) {
  return { product: await fetch(`/api/products/${params.id}`).then(r => r.json()) };
}

// Use both together - server for SSR, client for navigation
clientLoader.hydrate = true; // Force client loader during hydration

Form Handling & Actions:

// Server action
export async function action({ request }: Route.ActionArgs) {
  const formData = await request.formData();
  const result = await updateProduct(formData);
  return redirect(href("/products"));
}

// Client action (takes priority if both exist)
export async function clientAction({ request }: Route.ClientActionArgs) {
  const formData = await request.formData();
  await apiClient.updateProduct(formData);
  return { success: true };
}

// In component
<Form method="post">
  <input name="name" placeholder="Product name" />
  <input name="price" type="number" placeholder="Price" />
  <button type="submit">Save Product</button>
</Form>

File Naming Best Practices:

  • Use descriptive names that clearly indicate purpose
  • Use kebab-case for consistency (product-details.tsx)
  • Organize by feature rather than file naming conventions
  • The route configuration is the source of truth, not file names (app/routes.ts)

Error Handling & Boundaries

Route Error Boundaries:

Only setup ErrorBoundarys for routes if the users explicitly asks. All errors bubble up to the ErrorBoundary in root.tsx by default.

export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
  if (isRouteErrorResponse(error)) {
    return (
      <div>
        <h1>{error.status} {error.statusText}</h1>
        <p>{error.data}</p>
      </div>
    );
  }

  return (
    <div>
      <h1>Oops!</h1>
      <p>{error.message}</p>
    </div>
  );
}

Throwing Errors from Loaders/Actions:

export async function loader({ params }: Route.LoaderArgs) {
  const product = await db.getProduct(params.id);
  if (!product) {
    throw data("Product Not Found", { status: 404 });
  }
  return { product };
}

Anti-Patterns to Avoid

❌ React Router v6 Patterns:

// DON'T use component routing
<Routes>
  <Route path="/" element={<Home />} />
</Routes>

❌ Manual Data Fetching:

// DON'T fetch in components
function Product() {
  const [data, setData] = useState(null);
  useEffect(() => { fetch('/api/products') }, []);
  // Use loader instead!
}

❌ Manual Form Handling:

// DON'T handle forms manually
const handleSubmit = (e) => {
  e.preventDefault();
  fetch('/api/products', { method: 'POST' });
};
// Use Form component and action instead!

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Local Agent

73.34%
按下载量换算81

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills