ZYVOPMulti-Platform Sync
SeriesAI NewsWhy ZyVOPJoin Discord
LoginGet Started
ZYVOP
The Developer Publishing Hub
PrivacyTermsGuidelinesDMCACommunity
© 2026 ZyVOP
HomeFile-Based vs. Directory-Based Routing: Understanding the Difference

File-Based vs. Directory-Based Routing: Understanding the Difference

James 'Dante' Midzi
James 'Dante' Midzi
Solutions Architect
·
November 24, 2024
2 min read
Originally published ondantedecodes.vercel.app
File-Based vs. Directory-Based Routing: Understanding the Difference
Article

I don't know who did it, and why everyone is suddenly confused by this. What you are calling file-based routing is not what you claim. I will gladly explain.

I am going to use Next.js as an example:

File Based

This is file-based routing:

src/
└── pages/
    ├── index.js
    ├── about.js
    └── contact.js

Enter fullscreen mode Exit fullscreen mode

In the folder that defines your pages, if you are able to create a file in there and it automatically becomes a page (contact, about, services etc) that is file based routing.

File-based routing is a routing where the entry point to your routes is an index file. What that mean is the same way you can have a contact.jsx , you could also make a contact/index.js and these two would do exactly the same with little to no issues.

Frameworks that employ this:

  • Astro

  • Eleventy

  • Nextjs (with pages)s

  • Vue

  • Svelte


Directory Based

This is directory based routing

src/
└── app/
    ├── page.js
    ├── about/
    │   └── page.js
    └── contact/
        └── page.js

Enter fullscreen mode Exit fullscreen mode

With this way, there is a defined method of creating new pages i.e a folder with the file name and a special file within it.

When using this way, anything that does not follow this pattern is not regarded a page.

Frameworks that use this

  • Nextjs (with app)

  • SvleteKit


A Table To Know What You Are Using

Ask

File-Based Routing

Directory-Based Routing

Can I make a file name as a route and it works?

Yes

No

Can I create a folder with an index file and that will become the page?

Yes

No

Do I have a special naming convention for pages?

No

Yes

With this clarification at hand, can you all stop confusing this? You can? Thank you.


Thank you for reading, let's connect!

Thank you for visiting this little corner of mine. Let's connect on Twitter, Discord and LinkedIn

Comments (1)

Join the discussion by logging into your account.

ZyVOP

ZyVOP

Word WarriorEarly Bird
1 month ago

Easy explanation

James 'Dante' Midzi
James 'Dante' Midzi

Solutions Architect

Knowledge and the sharing of it drives me. Along with improvement each day

Subscribe to James 'Dante' Midzi 's Newsletter

Direct email dispatches when new stories are published. Zero algorithms.

Like
Love
Clap
Fire
Party
Wow

More from James 'Dante' Midzi

View profile

The Reason I Prefer Opinionated UI Libraries

Explore how opinionated UI libraries like Nuxt UI simplify form handling and reduce boilerplate, compared to headless kits like ui‑thing.

3 minSep 3

Why I Avoid shadcn/ui: Design Homogenisation & Hype

Explore why shadcn/ui may lead to generic, Bootstrap‑like sites and how LLMs amplify the trend, plus my reasons for skipping this popular UI kit.

2 minSep 1

The 'AI' Problem Noone Is Talking About

In a world where the physical books are gone and one company controls your access to those digital copies, nothing stops them from denying you access.

4 minAug 25

Are You Crippled By Your Preferences

In my head as a developer, you're supposed to be able to learn anything you're driven to. Your driving tenet should be to learn. If you don't understand something you take the time to learn what it wants not what you want.

3 minAug 17

Strict Types Won't Fix Your Lack of Understanding

In development circle I am what would be considered a mid/senior developer. I have been in the trenches, seen the rise and fall of technologies. Seen the prophe...

4 minAug 7