Introduction

NextJs is a flexible React Framework that gives you building blocks to create fast Web Applications. Basically, it provides some of the crucial features and building blocks on top of a standard React.js application to make a modern website and apps.

NextJS Folder Structure

.next

public

src/app

Static routes are given priority over dynamic routes

Link tag in Next and link Prefetching

React Server Components

Motivation

Developers constantly have to make choices about using third-party packages. Using a package to render some markdown or format a date is convenient for us as developers, but it increases code size and hurts performance for our users.

React's new Server Components compliment Server-side rendering, enabling rendering into an intermediate abstraction format without needing to add to the JavaScript bundle. This both allows merging the server-tree with the client-side tree without a loss of state and enables scaling up to more components.

Server Components are not a replacement for SSR.

It's been considered a best-practice to only serve code users need as they need it by using code-splitting.

Some of the challenges with code-splitting are: