Cursor·Fixpromptingbeginner

Cursor Generating Pages Router Instead of App Router

Quick Answer

Without .cursorrules specifying App Router, Cursor defaults to older Pages Router patterns from its training data. Start with "Add framework rules to .cursorrules" before making broader code changes.

You're in the right place if...

  • !Creates pages/ instead of app/ files
  • !Uses getServerSideProps instead of server components
  • !Generates _app.tsx

Why this happens

Without .cursorrules specifying App Router, Cursor defaults to older Pages Router patterns from its training data.

Fix

1

Add framework rules to .cursorrules

Add this to your .cursorrules file:

CRITICAL: This project uses Next.js 14 App Router ONLY.

Never generate:
- pages/ directory files
- getServerSideProps
- getStaticProps
- _app.tsx

Always generate:
- app/ directory files
- Server Components by default
- 'use client' only when needed

Prevent this next time

Always create .cursorrules with your Next.js version before starting any project in Cursor.

Frequently Asked Questions

The AI was trained on code from before App Router was standard. .cursorrules overrides this.

In App Router, use async server components instead. Data fetching happens directly in the component.

Related fixes

Weekly Newsletter

Get next week's fix before you need it.

Join developers getting weekly vibe coding tips, error fixes, and tool updates.

Subscribe on Substack →