react-router-code-review

Review React Router v6.4+ code for data loading, mutations, error handling, and navigation patterns.

75|9|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/anderskev/beagle --skill react-router-code-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-router-code-review
Source: https://github.com/anderskev/beagle/tree/main/skills/react-router-code-review
Command: npx skills add https://github.com/anderskev/beagle --skill react-router-code-review

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides reviewers in assessing React Router code for proper data loading, mutations, error handling, and navigation patterns.

Core Features & Use Cases

  • Data loaded via loader patterns vs useEffect and proper defer usage.
  • Mutations with Form/useFetcher patterns and robust action handling.
  • Error boundaries with errorElement and proper error types.
  • Declarative navigation with Link and appropriate pending states.

Quick Start

Review route definitions to ensure loaders handle errors, mutations use Form/useFetcher, and navigation uses Link over imperative navigation where possible.

Frequently Asked Questions about react-router-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review React Router loaders and actions for best practices?

React Router loaders handle data fetching before route renders, while actions process mutations. Review that loaders return data or redirect on error, actions validate input and use proper error types, defer defers non-critical data to enable streaming, and errorElement catches loader/action failures with isRouteErrorResponse checks.

What's the difference between using Form and useFetcher in React Router?

Form submits to the nearest action, triggering a navigation and full route transition. useFetcher submits without navigation, ideal for non-blocking mutations like optimistic UI updates. Choose Form for page-changing actions; useFetcher for isolated form interactions, pending states, and revalidation without route changes.

How should I handle errors in React Router loaders and actions?

Throw errors from loaders and actions; React Router catches them and renders the nearest errorElement. Use isRouteErrorResponse to detect route-specific errors versus unexpected exceptions. Place errorElement at route level to catch its loader and action, or at parent level for nested fallbacks across the entire route tree.

When should I use Link versus imperative navigation in React Router?

Link is declarative and preferable for user-initiated navigation—it works with prefetch, maintains browser history, and supports pending states via useNavigation. Use imperative navigate only after async operations (form submission success, confirmation dialogs) where declarative routing isn't possible.

Can I pass type-safe route parameters through React Router loaders?

Define route parameters in the route definition and access them via loader params argument. Use TypeScript to type params based on your route pattern—param keys match the :paramName segments. Loaders receive typed params, enabling safe access to IDs, slugs, and other dynamic values without runtime checks.

How does defer improve React Router data loading performance?

defer delays loading non-critical data until after the route renders. The loader returns a promise wrapped in defer(), and the route suspends the non-critical portion while rendering critical content. This enables streaming responses and faster perceived performance compared to awaiting all data in the loader.