Home › React Router / Remix › React Router 7 framework mode rules

React Router 7 framework mode rules

Cursor rules for React Router 7 in framework mode (the Remix successor): loaders, actions, and type-safe routes.

CursorReact Router / Remix

How to use

Save this as .cursor/rules/react-router.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.cursor/rules/react-router.mdcDownload  
---
description: React Router 7 framework mode conventions
globs: ["app/**/*.{ts,tsx}"]
alwaysApply: false
---

# React Router 7 (framework mode)

- Routes are declared in `app/routes.ts` using `route()`, `index()`, `layout()` and `prefix()`. Add a file and register it there; don't assume file-based routing unless `@react-router/fs-routes` is set up.
- Import generated types per route: `import type { Route } from "./+types/<name>"` and type `loader`, `action`, and the component with `Route.LoaderArgs`, `Route.ComponentProps`.
- Read data in `loader` (server) or `clientLoader` (browser only). Mutations go in `action` and are triggered by `<Form method="post">` or `useFetcher()`, not by `fetch` in an effect.
- Return plain objects from loaders; use `data(value, { status })` for status codes and `redirect()` for navigation. `json()` and `defer()` are legacy.
- Validate `formData` and params on the server (zod or the project's validator) and return field errors from the action.
- Pending UI from `useNavigation()` / `fetcher.state`; optimistic UI from `fetcher.formData`.
- Every route that can fail exports an `ErrorBoundary`. Set `meta` per route.
- Server-only code lives in `*.server.ts` files so it never ships to the client.

## Don't
- Don't import from `@remix-run/*` or `react-router-dom`; use `react-router`.
- Don't put secrets or DB clients in modules imported by components.

## Done when
`npm run typecheck` (runs `react-router typegen`) and `npm run build` pass.

More: all React Router / Remix rules · all Cursor rules

Related rules

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Chrome extension (Manifest V3) rules

Cursor rules for building Manifest V3 browser extensions with TypeScript and minimal permissions.

CursorChrome extensions

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.js

Nuxt 3 + Vue rules

Cursor rules for Nuxt 3 / Vue 3 apps using the Composition API, script setup and Pinia.

CursorVue / Nuxt

React 19 + Vite SPA rules

Cursor rules for React 19 single-page apps on Vite 6+ with TypeScript, hooks, and Vitest.

CursorReact

shadcn/ui component rules

Cursor rules for shadcn/ui with Tailwind CSS v4 and Radix: adding, composing, and theming components.

Cursorshadcn/ui

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.