Cursor·Fix

Fix: Cursor Generates Deprecated or Outdated Code Patterns

Quick Answer

Add this to .cursorrules: 'IMPORTANT: This project uses Next.js 14+ App Router. NEVER use Pages Router patterns (getServerSideProps, getStaticProps, pages/ directory). Use server components, generateMetadata, and the app/ directory exclusively.'

Quick Fix Summary

IssueGenerating deprecated or outdated code
Fastest fixUpdate .cursorrules with version constraints
Use this page ifCursor uses getServerSideProps instead of server components

Symptoms

  • !Cursor uses getServerSideProps instead of server components
  • !AI creates pages/ directory instead of app/ directory
  • !Generated code uses next/router instead of next/navigation
  • !Code uses deprecated React lifecycle methods

Step-by-Step Fix

1

Update .cursorrules with version constraints

Add explicit version constraints: 'Next.js 14+ (App Router only), React 18+ (hooks only, no class components), TypeScript 5+. Do NOT use any deprecated APIs.'

2

Show the AI your actual Next.js version

Include @package.json in your prompt so Cursor can see your actual dependency versions. It will generate code matching those versions.

3

Reject and re-prompt

When Cursor generates deprecated code, say: 'This uses getServerSideProps which is deprecated in App Router. Rewrite using a server component with async data fetching directly in the component.'

4

Provide a modern example

Include a working file: @src/app/page.tsx 'follow this exact pattern for data fetching — no getServerSideProps, no getStaticProps, just async server components.'

Frequently Asked Questions

The AI was trained on code from before Next.js 14. Without your .cursorrules specifying the version, it defaults to older patterns it saw more frequently during training.

getServerSideProps/getStaticProps (use server components instead), pages/ directory (use app/), next/router (use next/navigation), and React class components (use functional components with hooks).

Related

Weekly Signals

Get the next fix, switch, or warning before it hits your build.

Join builders getting the community signals, fix patterns, and tool shifts that matter before they show up everywhere else.

Follow the signals →