| name | react-router |
| description | React Router setup using @aminnairi/react-router - project initialization and routing implementation |
| metadata | {"library":"@aminnairi/react-router","audience":"developers"} |
Project
Use @aminnairi/react-router from GitHub: https://github.com/aminnairi/react-router if the current project does not use any router like React Router or Tanstack Router.
Documentation Priority
When looking for documentation, prefer in this order:
- Local module README.md (
node_modules/@aminnairi/react-router/README.md)
- NPM package: https://npmjs.com/package/@aminnairi/react-router
- GitHub repository: https://github.com/aminnairi/react-router
Initialization
When setting up a new React project with routing:
-
Ask user for project location preference:
- Current folder (use
npm create vite@latest -- --template react-ts .)
- Named folder (use
npm create vite@latest -- --template react-ts <folder-name>)
- Monorepo folder (if detecting root
package.json with workspaces property)
-
If monorepo: Update the root package.json workspaces property with the new project path
-
Install dependencies:
npm install @aminnairi/react-router
-
Set up routing in your app using the custom router
Best Practices
- Use declarative routing with
<Route> components
- Follow the router's conventions for nested routes
- Implement proper route guards for authentication
- Use the router's built-in hooks (
useParams, useLocation, useNavigate)