react-router-v7-patterns

Implement nested-route patterns for React Router v7 data routers.

2|Updated May 10, 2026
One-click install
npx skills add https://github.com/freedomw1987/tree_monstor --skill react-router-v7-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-router-v7-patterns
Source: https://github.com/freedomw1987/tree_monstor/tree/main/skills/frontend/react-router-v7-patterns
Command: npx skills add https://github.com/freedomw1987/tree_monstor --skill react-router-v7-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill eliminates common bugs and unexpected behavior when refactoring single-page applications to use nested routes with React Router v7 and v6.4+ data routers, such as mismatched tab active states, dropped query strings during redirects, duplicate layout headers, and stale component state from route reuse.

Core Features & Use Cases

  • 4 Proven Nested Route Patterns: Covers URL-driven tab state, query string preservation during backward-compatible redirects, layout chrome ownership to avoid double rendering, and search param synchronization to fix component reuse race conditions.
  • Decision Trees & Detection Signals: Includes guidance to choose between <Navigate> redirects and re-pointing links, plus signals to audit for broken query string deep links.
  • Worked Real-World Example: Draws on class-level lessons from a production CRM system refactor that converted 5 top-level admin routes into a nested /settings/* tabbed layout.
  • Use Cases: Refactoring top-level routes into nested sub-route trees, building tabbed settings/admin interfaces, debugging "URL shows X but page displays Y" bugs, and implementing backward-compatible route redirects.

Quick Start

Use this skill to fix a bug where clicking a settings tab updates the URL but the active tab highlight remains on the previous tab, or to refactor your existing top-level admin routes into a nested /settings/* sub-route structure with tabbed navigation.

Frequently Asked Questions about react-router-v7-patterns

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

FAQPage Schema
How do I fix React Router v7 nested route bugs where the active tab highlight doesn't update?

Fix React Router v7 nested route tab highlight bugs by implementing URL-driven tab state patterns. This synchronizes the active tab UI state directly with the URL parameters, ensuring the page displays the correct component when the URL changes.

Why does my React Router v7 redirect drop query string parameters?

React Router v7 redirects drop query string parameters when not explicitly preserved. Use query string preservation patterns during backward-compatible redirects to carry over existing search params and prevent broken deep links.

How to refactor top-level React routes into a nested tabbed settings layout?

Refactor top-level React routes into a nested tabbed settings layout by applying layout chrome ownership patterns. This prevents duplicate layout headers and ensures the parent route renders the shell while child sub-routes render the tab content.

What causes stale component state from route reuse in React Router v7 data routers?

Stale component state from route reuse in React Router v7 data routers is caused by component reuse race conditions. Apply search param synchronization patterns to force proper state resets when navigating between nested sub-routes.

When should I use Navigate redirects versus re-pointing links for React Router v7 backward compatibility?

Use Navigate redirects versus re-pointing links for React Router v7 backward compatibility based on decision tree signals. Choose Navigate when you need to sunset old paths entirely, and re-point links when consolidating routes into a nested sub-route tree.

Does this work with v6.4+ data routers or only React Router v7?

These nested route patterns work with both React Router v7 and v6.4+ data routers. The implementation patterns for tabbed layouts, query string preservation, and search param synchronization apply across both versions to eliminate SPA refactoring bugs.