# Routing

## Adding a New Route

Both steps are required — skipping step 1 causes a silent 404.

1. **Register in `app/routes.ts`** (do this first):
   ```typescript
   route("admin/sports-seasons/:id/new-page", "routes/admin.sports-seasons.$id.new-page.tsx")
   ```
   Nested admin routes go inside the `route("admin", ...)` array.

2. **Create the file** in `app/routes/` with the matching name.

3. Export `loader` / `action` as needed. TypeScript types are auto-generated via `react-router typegen`.

## File Naming Conventions

- `.` separates path segments: `leagues.$leagueId.settings.tsx` → `/leagues/:leagueId/settings`
- `$param` = dynamic segment
- `_index.tsx` = index route for a path

## Admin Routes

All admin routes are nested under `/admin` and require `isAdmin: true` on the user:

| Prefix | Area |
|---|---|
| `admin.sports.*` | Sports management |
| `admin.sports-seasons.*` | Sports seasons |
| `admin.templates.*` | Season templates |
| `admin.data-sync.tsx` | Data sync utilities |
