Why You Should Use Next.js for Your Next Web Application

Jazmine Foxworth
3 min readNov 9, 2020

If you’ve heard of React chances are you’ve likely heard about Next.JS as well. Released in October of 2016, Next.js is a front-end framework built on top of React that was designed to address some of the most common problems developers faced when building applications in React including client/server-side rendering, compiling, bundling, and more. Some of these problems sound familiar? Let’s take a look at how Next.js is designed to help ease those pains and make building easy again.

Next.js vs. React: What’s better?

I know this may sound strange, but these two really can’t be compared. Next.js is a React framework. Taking a step back, React is a library for creating user interfaces. Next.js is built on top of React and is designed for server-rendered React applications. The Next.js framework allows React apps to be rendered on the server. Therefore, you cannot compare the two because they work in tandem. Together, they provide a combined structure that allows you to build a front-end React application that handles server-side rendering with ease.

Why Next.js?

There are a number of reasons why you’d want to use Next.js to tackle your next big project. Here are a few:

Server-Side Rendering

For years, engineers have been struggling to figure out how to create applications that take advantage of server-side render while not sacrificing the user experience found in client-side routing. This is the problem that the creators of Next.js were hoping to solve when they created the framework.

Next.js enables server-side rendering and generating static sites for React-based applications. Using server-side rendering, the HTML can be pre-rendered on the server on every request from the user. This means, that your HTML is ready to go and not in a bundle that your browser needs to execute upon arrival. Thanks to this feature, you’ll see better SEO results for your website, which using Next.js ideal for creating blogs, social media applications, and brand-based websites.

Styled JSX

Typically in your React apps, all style sheets are bundled as a long CSS file. Once bundled, the details from the file will then be applied globally. This can later lead to issues that cause unwanted styling on the wrong elements, and tracking down these bugs can be long and arduous. Next.js introduced styled-jsx to solve this issue. Using this tool you can write component-based scoped CSS/SASS.

Bundle, compile, repeat…

In order to build out your apps in React you must have a deep understanding of how to bundle and compile your app, right? Not with Next.js! Upon installation, Next.js features next/babel presets that compiles your code and a web pack-based development environment that supports Hot Module Replacement (HMR). Using HMR and the included next/babel presets, you’ll save a lot of time and be able to begin focusing on what’s important to develop your app as soon as you get started.

How to Install and Get Started

As you can seethere are a load of benefits to working with Next.js when building out web applications. So, how do you get started?

First, you need to run the following command in your terminal to install the needed modules:

npm install react react-dom next

Then, all you’ll need to do create your npm package and set your scripts as follows:

“scripts”: { “dev”: “next”, “build”: “next build”, “start”: “next start”}

Good luck and happy coding!

--

--