vibe-stack / rules
Cursor rule8 starsChanged 8 months agoMITView on GitHub
Prevent common React 19 and Next.js 15 migration pitfalls
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/ai-collaboration.mdcCursor rule
- .cursor/rules/api-design.mdcCursor rule
- .cursor/rules/api-validation.mdcCursor rule
- .cursor/rules/caching-revalidation.mdcCursor rule
- .cursor/rules/context-management.mdcCursor rule
- .cursor/rules/database-design.mdcCursor rule
- .cursor/rules/env-management.mdcCursor rule
- .cursor/rules/error-handling.mdcCursor rule
- .cursor/rules/file-naming.mdcCursor rule
- .cursor/rules/file-uploads.mdcCursor rule
- .cursor/rules/git-conventions.mdcCursor rule
- .cursor/rules/hydration-safety.mdcCursor rule
- .cursor/rules/middleware-auth.mdcCursor rule
- .cursor/rules/nextjs15-params.mdcCursor rule
- .cursor/rules/performance.mdcCursor rule
- .cursor/rules/project-context.mdcCursor rule
- .cursor/rules/security.mdcCursor rule
- .cursor/rules/server-actions.mdcCursor rule
- .cursor/rules/server-vs-client-components.mdcCursor rule
- .cursor/rules/shadcn-patterns.mdcCursor rule
- .cursor/rules/stripe-payments.mdcCursor rule
- .cursor/rules/stripe-webhooks.mdcCursor rule
- .cursor/rules/supabase-auth-security.mdcCursor rule
- .cursor/rules/supabase-rls.mdcCursor rule
- .cursor/rules/supabase-ssr-only.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/typescript-strict.mdcCursor rule
- .cursor/rules/verify-before-use.mdcCursor rule
- llms.txtllms.txt
The file
Files
---
description: Prevent common React 19 and Next.js 15 migration pitfalls
globs: ["**/*.tsx", "**/*.ts"]
alwaysApply: false
---
# React 19 / Next.js 15 Migration Traps
## RULE 1: useFormStatus Must Be Inside <form>
`useFormStatus()` only works when the component using it is a CHILD of a `<form>`
element that uses a Server Action. It does NOT work if used in the same component
that renders the form.
```tsx
// ❌ WRONG — useFormStatus returns { pending: false } always
'use client'
export function MyForm() {
const { pending } = useFormStatus() // Always false here
return (
<form action={createItem}>
<Button disabled={pending}>Submit</Button>
</form>
)
}
// ✅ CORRECT — extract the submit button to a child component
'use client'
import { useFormStatus } from 'react-dom'
function SubmitButton() {
const { pending } = useFormStatus()
return <Button disabled={pending}>{pending ? 'Saving...' : 'Submit'}</Button>
}
export function MyForm() {
return (
<form action={createItem}>
<SubmitButton />
</form>
)
}
```
## RULE 2: useActionState Replaces useFormState
`useFormState` is DEPRECATED in React 19. Use `useActionState` instead.
```typescript
// ❌ DEPRECATED
import { useFormState } from 'react-dom'
// ✅ CORRECT — React 19
import { useActionState } from 'react'
const [state, formAction, isPending] = useActionState(serverAction, initialState)
```
## RULE 3: ref Is a Regular Prop in React 19
`forwardRef()` is no longer required. `ref` is passed as a regular prop.
```tsx
// ❌ DEPRECATED — verbose, unnecessary in React 19
const MyInput = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
return <input ref={ref} {...props} />
})
// ✅ CORRECT — React 19
function MyInput({ ref, ...props }: InputProps & { ref?: React.Ref<HTMLInputElement> }) {
return <input ref={ref} {...props} />
}
```
## RULE 4: use() Hook for Promises and Context
React 19 `use()` can unwrap Promises in render. Use it instead of useEffect for
data fetching in client components.
```tsx
// ✅ React 19 — use() for context (replaces useContext)
import { use } from 'react'
const theme = use(ThemeContext)
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

