skills/react-router-declarative-mode/SKILL.md
Build React applications using React Router's declarative mode with BrowserRouter. Use when configuring routes with JSX, navigating with Link/NavLink, or reading URL params and search params without data loaders or actions.
npx skillsauth add remix-run/agent-skills react-router-declarative-modeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Declarative mode is React Router's simplest mode using <BrowserRouter>, <Routes>, and <Route> for basic client-side routing without data loading features like loaders or actions.
<BrowserRouter> for routing<Routes> and <Route><Link>, <NavLink>, or useNavigateuseParamsuseSearchParamsuseLocationLoad the relevant reference for detailed guidance on the specific API/concept:
| Reference | Use When |
| -------------------------- | ------------------------------------------------- |
| references/routing.md | Configuring routes, nested routes, dynamic params |
| references/navigation.md | Links, NavLink active states, programmatic nav |
| references/url-values.md | Reading params, search params, location |
These are the most important patterns to follow. Load the relevant reference for full details.
Configure routes with JSX using <Routes> and <Route>:
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="about" element={<About />} />
<Route path="dashboard" element={<Dashboard />}>
<Route index element={<DashboardHome />} />
<Route path="settings" element={<Settings />} />
</Route>
<Route path="users/:userId" element={<User />} />
</Routes>
</BrowserRouter>
);
}
Use NavLink for navigation with active styling:
import { NavLink } from "react-router";
function Nav() {
return (
<nav>
<NavLink
to="/"
end
className={({ isActive }) => (isActive ? "active" : "")}
>
Home
</NavLink>
<NavLink
to="/dashboard"
className={({ isActive }) => (isActive ? "active" : "")}
>
Dashboard
</NavLink>
</nav>
);
}
Use useParams to read dynamic route segments:
import { useParams } from "react-router";
function User() {
const { userId } = useParams();
return <h1>User {userId}</h1>;
}
Use useSearchParams for query string values:
import { useSearchParams } from "react-router";
function SearchResults() {
const [searchParams, setSearchParams] = useSearchParams();
const query = searchParams.get("q");
return (
<div>
<input
value={query || ""}
onChange={(e) => setSearchParams({ q: e.target.value })}
/>
<p>Results for: {query}</p>
</div>
);
}
If anything related to React Router is not covered in these references, you can search the official documentation:
https://reactrouter.com/docs
development
Build full-stack React applications using React Router's framework mode. Use when configuring routes, working with loaders and actions, handling forms, handling navigation, pending/optimistic UI, error boundaries, or working with react-router.config.ts or other react router conventions.
tools
Build React applications using React Router's data mode with createBrowserRouter and RouterProvider. Use when working with route objects, loaders, actions, Form, useFetcher, or pending/optimistic UI without the Vite plugin.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.