react-routing

Implements guarded, code-split React Router 7 routes with permission checks and URL-driven state.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-routing-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-routing
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/react-routing
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-routing-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Routes in a multi-tenant SPA are security boundaries, and ad-hoc routing leads to unguarded pages, duplicated permission checks, silent redirects, and leaked internal IDs. This Skill enforces a consistent discipline for defining, guarding, and structuring routes in a React Router 7 application. ## Core Features & Use Cases - Guarded route patterns: Standard <ProtectedRoute> and <AdminRoute> wrappers that centralize authentication and RBAC permission checks instead of scattering them across components. - Per-route code splitting and error isolation: Lazy-loaded routes each wrapped in their own <Suspense> and <ErrorBoundary> so one slow or crashing feature never blocks the whole app. - URL as source of truth: Search-param state via useSearchParams for filters, sort, and pagination, plus expired-session redirect flows that preserve the intended destination. - Use Case: When adding a new admin analytics page, apply this Skill to declare the route in AppRoutes.tsx, wrap it with <AdminRoute requiredPermission="...">, lazy-load the view, and keep its filters in the URL. ## Quick Start Add a new admin-only route for the reports page using the protected route guard, lazy loading, and search-param filter state.

Frequently Asked Questions about react-routing

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

FAQPage Schema
How do I add a protected route in React Router 7?

Wrap the route element in a ProtectedRoute component that reads auth state from useAuth and redirects unauthenticated users to /login with a ?from parameter for return-after-login. Declare the route in AppRoutes.tsx so all routes stay discoverable in one place.

How do I implement role-based route guards in React?

Compose an AdminRoute on top of the authentication guard that checks a requiredPermission against the user's effective permissions. Redirect denied users to a visible no-access page rather than silently navigating them home.

Should I use React Router loaders or TanStack Query for data fetching?

This codebase fetches data with TanStack Query hooks inside route components, not React Router loaders. Introducing loaders is a structural change requiring an architecture decision record; use queryClient.prefetchQuery for preloading instead.

How do I code split routes with React lazy and Suspense?

Use React.lazy to import each heavy route component and wrap each one in its own Suspense with a spinner fallback. Per-route Suspense keeps the rest of the app interactive while one route loads, unlike a single root-level boundary.

Why should filter and pagination state live in the URL?

URL search params via useSearchParams make state shareable, bookmarkable, and survive navigation. Storing route-shaped state in Zustand or component state breaks deep-linking and duplicates the source of truth.

When should permission checks not live inside route components?

Permission checks belong in route guards, not duplicated across components. If multiple route components repeat the same canX check with a redirect, that logic should move into a shared guard treated as a security boundary.