Containerize your Next.js apps in a jiffy
Containers are a unit of software that help us package our code and our dependencies compactly. The main advantage of this is it helps our apps to run efficiently and reliably in various environments.
When we package our code and dependencies, a Docker image is created. This image encompasses everything that’s required for our app to run, including the system tools and libraries as well.
When we build these images and run them, they become Docker containers. Once again, for emphasis, the huge advantage of doing so is to help our software run in the same exact way, no matter what OS you’re using under the hood — be it Linux or Windows, etc. This uniformity that Docker containers help us provide is crucial, especially when deploying apps for production.
In recent times, containerized apps have largely taken over the traditional method of running apps via virtual machines (VMs). VMs require a full copy of the underlying OS to run, and you can imagine how much space the overall duplication of the system’s libraries, tools, etc. would consume!
Now that we’ve covered a summary of containers, let’s start containerizing our Next.js app.
For the purposes of the demo, we’ll create a brand new Next.js project using the following command:
yarn create next-app
Follow and answer the prompts to complete creating a new Next.js project.
Let’s test everything is running fine by running
yarn dev inside the project directory.
Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.
I have been using React JS in my projects for quite some time now and am used to managing routing in my app using the react-router package. I have always been keen on having as little dependencies in my apps as possible, so, I always felt perturbed by the use of this particular package in simpler apps which did not have complex routes.