create-route
Create React Router 7 routes with proper type imports, loaders, and actions. Use when adding new pages, API endpoints, layouts, or route files.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Create Route
When to Use
- Creating new pages or views
- Adding API endpoints
- Creating layout routes with
<Outlet />
Critical Rules
1. Route Type Imports
// ALWAYS use this pattern:
import type { Route } from './+types/my-route';
// NEVER use relative paths:
// import type { Route } from '../+types/my-route'; // WRONG!
If types are missing: Run npm run typecheck - NEVER change the import path.
2. Destructure Directly
// CORRECT
export async function action({ request, params }: Route.ActionArgs) {}
// WRONG
export async function action(args: Route.ActionArgs) {
const { request } = args; // Don't do this!
}
3. Access Data via Props
// CORRECT
export default function MyPage({ loaderData }: Route.ComponentProps) {}
// WRONG
const data = useLoaderData(); // Don't use hooks!
Quick Start
import type { Route } from './+types/my-page';
import { data, redirect } from 'react-router';
export async function loader({ request }: Route.LoaderArgs) {
const user = await requireUser(request);
return { user };
}
export async function action({ request }: Route.ActionArgs) {
const formData = await request.formData();
// Handle POST/PUT/DELETE
return redirect('/success');
}
export default function MyPage({ loaderData }: Route.ComponentProps) {
return (
<>
<title>Page Title | Iridium</title>
<meta name="description" content="Description" />
{/* Content */}
</>
);
}
Checklist
- Create route file in
app/routes/ - Register in
app/routes.ts - Run
npm run typecheckto generate types - Add path to
Pathsconstant if reusable
Templates
Full Reference
See .github/instructions/react-router.instructions.md for:
- Nested routes & layouts
- Dynamic segments & optional segments
- Streaming with Suspense
- Error boundaries
- Navigation patterns
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!