Skip to content
Back to skills

Create Route

ASecurity

Create React Router 7 routes with proper type imports, loaders, and actions. Use when adding new pages, API endpoints, layouts, or route files.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
developmentreactgitapi

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill create-route --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Route?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Route
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-create-route/badge)](https://www.skillsdirectory.com/skills/majiayu000-create-route)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: create-route
description: Create React Router 7 routes with proper type imports, loaders, and actions. Use when adding new pages, API endpoints, layouts, or route files.
---

# Create Route

## When to Use

- Creating new pages or views
- Adding API endpoints
- Creating layout routes with `<Outlet />`

## Critical Rules

### 1. Route Type Imports

```tsx
// 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

```tsx
// 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

```tsx
// CORRECT
export default function MyPage({ loaderData }: Route.ComponentProps) {}

// WRONG
const data = useLoaderData();  // Don't use hooks!
```

## Quick Start

```tsx
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

1. [ ] Create route file in `app/routes/`
2. [ ] Register in `app/routes.ts`
3. [ ] Run `npm run typecheck` to generate types
4. [ ] Add path to `Paths` constant if reusable

## Templates

- [Page Route](./templates/page-route.tsx)
- [API Route](./templates/api-route.ts)
- [Layout Route](./templates/layout-route.tsx)

## Full Reference

See `.github/instructions/react-router.instructions.md` for:
- Nested routes & layouts
- Dynamic segments & optional segments
- Streaming with Suspense
- Error boundaries
- Navigation patterns

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.