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)

Creating a Docker container for Next.js

Let's reiterate: Docker is a virtual machine with an OS that is capable of managing containers. So, how to bring the container image to a required tools, libs and settings? Via an instruction file, of course, because this process has to be reproducible on a dev machine, in staging, in production, and anywhere else.

A Dockerfile is a set of instructions that take a source image and bring it to a desired state, which results in an image too. Any existing Dockerfile's outcome image could in turn be taken as a source for another one, and so on.

Let's start with a super-minimal set of packages:

$ npm i react react-dom isomorphic-unfetch --save
$ npm i next --save-dev

Next, we create scripts in package.json as usual:

{
"scripts": {
"start": "next",
"build": "next build",
...