Performance: Why file-based routing simplifies navigation
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by simplifying route resolution and reducing runtime overhead.
Use Next.js file-based routing by creating files like pages/index.js, pages/about.js, pages/contact.js.
Navigate using <Link href="/about">About</Link> which Next.js handles automatically.const routes = { home: '/', about: '/about', contact: '/contact' }; function navigate(route) { const path = routes[route]; window.history.pushState({}, '', path); // manual route handling }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual route management with JS | Low | 0 | Low | [!] OK |
| Next.js file-based routing | Low | 0 | Low | [OK] Good |