Next.js is self-branded as the React framework for static pages, progressive web apps, mobile web apps, SEO-friendly pages, and — most especially — server-side rendering. It facilitates static exporting with just a line of command, ships with a CSS-in-JS library called Styled JSX, and includes features like code splitting, universal rendering, and hot reloading.
According to the “State of JavaScript 2019” survey, the Next.js community grew massively in the last 12 months: retention rate went from 6 percent all the way to 24 percent, and the number of new people who are willing to learn increased by almost 10 percent.
About three months ago, the Next.js team released a new starter boilerplate called Create Next App, and in this post, we will look into the new features that shipped with it.
Like the very popular Create React App, Create Next App is the easiest way to create a Next application, which is essentially a React app with server-side rendering.
It was actually initially a Next community project, but the team at Next felt that is was very important to be a major part of the first channels through which developers get to experience Next, so they got the maintainers to transfer ownership to them three months ago.
We worked with Segment to transfer ownership of the package, and are very grateful for their prior stewardship, especially by Fouad Matin.
Before this time, Next was already fully supporting the project, as they listed it in the official docs in the Next.js examples collection.
Create Next App was rebuilt from the ground up to perfectly represent the official starter pack qualities you would expect from Next. I personally think this was a great move, considering the amount of growth Next.js has seen in the past year. Now let’s look into some of the features you would see in create-next-app.
How do you feel when you run the npx command to create a new Next project? This is a critical point in your onboarding process, especially as a new Next developer. In the new revamp, the Next team has ensured a great experience when you run the command below:
npx create-next-app myApp
Even without any arguments at all, you get a whole interactive experience where you are guided through every step to set up a new project. This can be the turning point that makes a new user into a returning one, and Next has covered that really well.
With the new Create Next App boilerplate, you can start a project in a second today because it has no dependencies. According to the Next blog, the size of the starter app was about 5.4MB on the unofficial version, and after all the optimizations have been done, more than 4.7MB has been shredded off the app. Now on install, the Create Next App size is 604kB.
Amazing features like this one make a very convincing case for Next.js: this new version has offline support shipped with it. So if you’re working on your Next app and you go offline before starting a new project, it will both automatically detect that you are offline and also load up your project using your local package cache, which I think is super amazing and thoughtful.
Create Next App uses a new project template that is carefully designed for a modern Next.js application. Initially, versions on the current Next.js and versions displayed in Create Next App did not match, but now that the project is officially owned by Next.js, the template will always be up to date with the latest Next version.
This is another great feature that I am excited about. Next.js has a lot of code examples that show how to get started completing various tasks with Next. With this new release of Create Next App, you can now start up an application as a kind of instance of an example in the Next collection.
This is really brilliantly thought out, as I can assume that these examples are useful guides for Next developers. All you have to do is add the example name in your startup command, so if you wanted to deploy the blog starter example, all you have to do in your terminal is run the command below:
npx create-next-app --example blog-starter
This will automatically scaffold a Next.js app for you in the form it is illustrated in the Next blog starter example.
The new Create Next App is now part of the Next.js mono repository, so it is extensively tested with the very same integration test suite as the Next.js project itself. This ensures an ecosystem in sync, and everything just works in every release.
To get started using Create Next App, open up your terminal and change directory to your chosen folder. Run the command below:
npx create-next-app newapp
newapp
is the application name of your choosing. Remember to use all lowercase letters when naming to conform to the npm rule, so you don’t get errors like this:
Could not create a project called “newApp” because of npm naming restrictions: * name can no longer contain capital letters
If you get no errors, your terminal will successfully install the latest versions of React and Next:
+ [email protected] + [email protected] + [email protected] added 820 packages from 371 contributors and audited 8383 packages in 67.97s found 0 vulnerabilities
You can now change the directory to your new folder and run the dev server with:
npm run dev
Make sure you have admin rights on the machine you are using so you avoid access errors. Your app on localhost:3000
should look exactly like this:
In your file manager, you will see that everything you need at the start has been created for you, from the pages folder that contains the index.js
file to the component folder that has the nav file.
This post has shown you the new Next.js boilerplate called Create Next App, which is the officially supported Next.js starter application. We looked at all the new features one by one and also talked about how to get started using it. Tell me about your favorite features in the comments — happy hacking!
Debugging Next applications can be difficult, especially when users experience issues that are difficult to reproduce. If you’re interested in monitoring and tracking state, automatically surfacing JavaScript errors, and tracking slow network requests and component load time, try LogRocket.
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens on your Next.js app. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app's performance, reporting with metrics like client CPU load, client memory usage, and more.
The LogRocket Redux middleware package adds an extra layer of visibility into your user sessions. LogRocket logs all actions and state from your Redux stores.
Modernize how you debug your Next.js apps — start monitoring for free.
Hey there, want to help make our blog better?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowToast notifications are messages that appear on the screen to provide feedback to users. When users interact with the user […]
Deno’s features and built-in TypeScript support make it appealing for developers seeking a secure and streamlined development experience.
It can be difficult to choose between types and interfaces in TypeScript, but in this post, you’ll learn which to use in specific use cases.
This tutorial demonstrates how to build, integrate, and customize a bottom navigation bar in a Flutter app.