Book Image

Next.js Quick Start Guide

By : Kirill Konshin
Book Image

Next.js Quick Start Guide

By: Kirill Konshin

Overview of this book

Next.js is a powerful addition to the ever-growing and dynamic JavaScript world. Built on top of React, Webpack, and Babel, it is a minimalistic framework for server-rendered universal JavaScript applications. This book will show you the best practices for building sites using Next. js, enabling you to build SEO-friendly and superfast websites. This book will guide you from building a simple single page app to a scalable and reliable client-server infrastructure. You will explore code sharing between client and server, universal modules, and server-side rendering. The book will take you through the core Next.js concepts that everyone is talking about – hot reloading, code splitting, routing, server rendering, transpilation, CSS isolation, and more. You will learn ways of implementing them in order to create your own universal JavaScript application. You will walk through the building and deployment stages of your applications with the JSON API,customizing the confguration, error handling,data fetching, deploying to production, and authentication.
Table of Contents (9 chapters)

Caching

Caching could significantly improve the performance of the server because it will not try to request data from slow remote servers, but instead will access a fast local cache that can respond immediately.

We suggest using Redux on the client side because this will allow us to use Store as a runtime cache while the app is running. This approach also allows us to prepopulate some keys on the server when pages are loaded.

We recommend using client-side persistent storage for Redux extremely carefully, because improper usage may lead to state inconsistency between server and client: the server has sent some initial state, and the client then applies the extra initial state from localStorage (for example) and renders more than the server did, so you will get an error.

The client has to be smart enough to show the partial state from the server and then apply the delta coming...