Convention over Configuration

The framework treats standard file names and folders as instructions, so common behavior needs little or no setup.

folders magically become routeswhy does naming a file page.tsx make a pagethe framework already knows what my file names meanthere is no route config file anywherejust put the file in the right folder and it worksconvention over configrationRails magicwhich file names are reserved

What it is

Convention over Configuration means a framework supplies standard answers and infers behavior from names and locations instead of asking you to declare every rule. David Heinemeier Hansson made the phrase famous with Ruby on Rails in 2004, against a Java web stack drowning in XML. Next.js applies the same idea when app/shop/page.tsx becomes /shop and a neighboring loading.tsx becomes that route's loading UI.

Reach for it when the framework's normal path matches the product. Shared conventions remove setup files, make unfamiliar projects easier to scan, and let generators and tooling work from predictable structure. The value is not zero configuration; it is spending configuration only on choices that differ from the default.

The gotcha is invisible behavior. A misplaced or renamed file can stop being special without an obvious code change, and teams sometimes twist their domain model to satisfy a convention that no longer fits. Learn the framework's reserved names, document deliberate departures, and use an escape hatch when explicit configuration makes the behavior clearer.

Ask AI for it

Restructure this project around Next.js App Router conventions: use app/layout.tsx for the shared shell, page.tsx for each route, [slug] for dynamic segments, and colocated loading.tsx, error.tsx, and not-found.tsx files. Delete the duplicate hand-written route table, keep exceptional behavior explicit in next.config.ts, and add a short README table listing every reserved file name the team relies on.

You might have meant

routingdynamic routeboilerplatesmart defaultsstatic site generation

Go deeper