Performance: Why file-based routing simplifies navigation
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 |
index.js, about.js, [postId].js, what URL paths will Next.js automatically create?user.js inside the pages folder to handle user profiles, but navigating to /123 shows a 404 error. What is the likely problem?[userId].js to handle dynamic user IDs. correctly identifies the need for a dynamic route file name. Options A, B, and C are incorrect because Next.js supports .js files, automatic routing, and nested routes./blog/technology/123 where technology is a category and 123 is a post ID?Pass the test and this pattern moves unknown