Dev

Next.js has become one of the most popular frameworks for building React applications. With the introduction of the App Router, Next.js offers a new architecture that improves routing, data fetching, layouts, and overall application performance.
The App Router is the modern routing system introduced in Next.js 13. It is based on the app directory and provides powerful features such as Server Components, Nested Layouts, Streaming, and improved data fetching.
Basic structure:
app/
├── page.js
├── about/
│ └── page.js
└── blog/
└── page.js
Routes generated:
/ → Home page/about → About page/blog → Blog pageComponents are rendered on the server by default, reducing client-side JavaScript and improving performance.
App Router supports reusable layouts that can be nested across multiple routes.
Example:
export default function DashboardLayout({ children }) {
return (
<div>
<nav>Dashboard Menu</nav>
{children}
</div>
);
}
This layout automatically wraps all dashboard-related pages.
Data can be fetched directly inside Server Components.
async function Posts() {
const res = await fetch('https://api.example.com/posts');
const posts = await res.json();
return <div>{posts.length}</div>;
}
No need for getServerSideProps or getStaticProps.
App Router leverages React Suspense and Streaming to deliver content faster and improve user experience.
Defines a route page.
Defines shared layouts for routes.
Displays loading states during data fetching.
Handles route-level errors.
Creates custom 404 pages.
| App Router | Pages Router |
|---|---|
| app directory | pages directory |
| Server Components | Client-first approach |
| Nested Layouts | Limited layout support |
| Modern Data Fetching | getServerSideProps |
| Streaming Support | Limited support |
For new projects, App Router is the recommended approach. It represents the future of Next.js development and provides better performance, scalability, and developer experience.
The Next.js App Router introduces a modern and powerful routing architecture for React applications. With features like Server Components, Nested Layouts, Streaming, and simplified data fetching, it enables developers to build fast, scalable, and maintainable web applications.
More articles
More notes on web performance, design systems, and the craft of building digital products.
3 mins read
WordPress hooks are one of the most powerful features of the WordPress development ecosystem. They provide developers with a way to customize and extend WordPress functionality without modifying the core files. Hooks act as connection points where custom code can be executed during specific events or processes within WordPress.
Access all our articles in one place.
View articles
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion