DEV Community

Cover image for An Introduction to Next.js
Brandon Damue
Brandon Damue

Posted on

An Introduction to Next.js

A couple of months ago after learning and using React for a while, I decided to get my hands into the Next.js. This is a short article in which I'll be talking about the Next.js ecosystem, what it has to offer and my thoughts about it. So without any further long talk, lets get to it.

What is Next.js?

Next is an amazing flexible React framework built by Vercel that gives you building blocks for the development of web applications. It is considered a framework because it handles the tooling and configuration needed for React, and provides additional structure, features, and optimizations for your application. Simply put, Next is React on steroids. It is called React on steroids because of all the inbuilt features it ships with. You can use React to build your user interface, then incrementally adopt Next.js features to solve common application requirements such as routing, data fetching, and integrations. At the time of writing of this article, Next.js is at version 13.

Getting started with Next.js

To start enjoying the amazing features that Next.js offers, you need to have some knowledge in JavaScript and React as well as knowledge of some core web development concepts. The recommended way to initiate a new Next.js project is by using create-next-app which automatically sets up everything for you. So you don't have to create an empty directory to get started cause create-next-app makes one for you. To create a project, run:

npx create-next-app@latest
# or
yarn create next-app
# or
pnpm create next-app
Enter fullscreen mode Exit fullscreen mode

Since Next offers out of the box support for TypeScript, you can start a TypeScript Next project by using the --typescript flag:

npx create-next-app@latest --typescript
# or
yarn create next-app --typescript
# or
pnpm create next-app --typescript
Enter fullscreen mode Exit fullscreen mode

After the installation is complete:

What is covered above is the automatic setup to get Next.js up and running. There is also a manual way to setup Next.js. We won't be going into that though but if you are curious and want to know how it is done, you can look it up here.

Next.js Features

Now let's talk about the amazing features and optimizations Next.js offers to developers to help them develop applications in a faster and more effective way. Hope you are ready? Let's get into it!

  • Next.js is ecosystem friendly in that it offers out-of-the-box support for JSX, TypeScript, CSS and more.
  • It offers native support for images and fonts. Amongst other image optimization features, Next offers image lazy loading.
  • You can't talk about the top features that Next.js ships with without talking about its SEO support.
  • Next offers a file-system based router built on the concept of pages. What this means is that when a file is added to the pages directory of your Next project, it's automatically available as a route. Learn more here
  • Next.js makes SSR(Server Side Rendering) possible without any complex configurations.

My thoughts about Next.js

The first thing I'll like to outline is the fact that my transition from using React to using Next was very smooth so I'd say Next has a somewhat easy learning curve. Next.js offers wonderful support for SEO so I don't worry that a web application will not be properly indexed by search engines. Another thing I love about Next.js is that it has a great and ever-growing community around it.

Outro

Next.js offers a plethora of benefits for you to build and deploy your application. If you are using React and you want an easier and more enjoyable workflow when it comes to doing things like data fetching, server-side rendering and building a product that is SEO friendly, or you want a JavaScript framework that can be used to build robust applications, I suggest you should look in the direction of Next.js. Thank you for giving this article a read, you can connect with me on Twitter @flaacko_flaacko. Until 'Next' time it's goodbye from me.

Top comments (0)