Skip to main content

Which folders are required?

In Next.js there is no "strictly required" structure - everything is maximally lazy. But there is a minimum without which the application makes no sense.

Required folders (in practice)

app/ or pages/

At least one of them

  • app/ - the modern standard (App Router)
  • pages/ - the old Pages Router

Without one of them, there will be no routing at all.


What is required inside app/

page.tsx

At least one page

txt
app/page.tsx → /

Without page.tsx:

  • the build will succeed
  • but there will be no pages at all

Not required (but often needed)

layout.tsx

  • not required
  • but if page.tsx exists, Next creates a default layout itself

However, in a real project a layout is almost always needed


loading.tsx

Skeleton / fallback Not required


not-found.tsx

Custom 404 Not required


error.tsx

Error Boundary Not required


Other folders are entirely optional

FolderRequiredPurpose
components/NoUI components
features/NoFSD
shared/Noutilities, UI
styles/Noglobal styles
lib/Nohelpers, services
public/Nostatic assets
api/Nobackend routes
hooks/Nocustom hooks

Next requires none of this.


Minimally valid project

txt
app/ └─ page.tsx

Yes, this is genuinely enough.


Common misconceptions

"layout.tsx is required" → no

"components/ is needed" → no

"_app.tsx is needed" → only in pages/

"without public/ the project won't start" → it will start


Practical takeaway

Next.js ≠ a framework with a rigid architecture

It:

  • provides routing rules
  • but does not impose a structure

You decide:

  • FSD / MVC / flat
  • monorepo / single
  • frontend-only or fullstack

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.