NextJS and Create-React-App. What is the difference?
We publish a new translation for aspiring React developers. We hope this article will help you in choosing the right tool for your next project.
When it comes to creating new projects in React, we have an obvious choice: NextJS or Create-React-App. Gatsby is largely out of use due to slow builds when scaling. In addition, NextJS is becoming an increasingly convenient static site generator.
The photo Artem Sapegina on Unsplash
In this article, we’ll take a look at the advantages and disadvantages of NextJS and Create-React-App, and discuss which use cases are right for each.
Create-React-App is a set of tools that allows you to create new React applications. The CRA stores dependencies like webpack and babel inside react scripts. Create-React-App makes it easy to work with transpilers and bundlers.
This means that updating these “hidden” dependencies is not difficult at all. You need to wait for a new release of react scripts and update. We don’t have to mess around with fixing breaking webpack configuration changes.
Benefits of using Create-React-App
Any library can be used, there are no rules or guidelines. The choice of the library for routing is also at your discretion.
Create-React-Apps renders client-side
Since we are rendering Create-React-Apps on the client side, deployment is easy. We can host the application on any file hosting, for example, on S3. CSR applications are much easier to work with!
Disadvantages of Create-React-App
Difficult to set up
There is no built-in way to customize the app. If you need to tweak webpack configuration, your only option is to use a third party tool like craco or eject. However, after running the eject command, you will lose almost all the benefits of using Create-React-App.
It abstracts complexity
Create-React-App works great as long as you don’t have to do what it doesn’t support. It will be hard! By hiding the babel and webpack config, Create-React-App makes getting started easier. However, this prevents developers from learning more about how these vital tools work.
Negatively affects SEO
Since we are rendering Create-React-Apps client-side, the tool is tricky to implement SEO. Create-React-Apps shouldn’t be used for e-commerce or marketing purposes.
It’s not entirely correct to compare NextJS and Create-React-App, because NextJS is so much more. While CRA is just a tool for building React app templates, NextJS is a framework for building React apps. Out of the box, NextJS provides server side rendering, static site creation, serverless functionality, and more. This is a whole set of tools that gives us everything we need to create effective web applications.
Want to take it even further with NextJS? Try HappyKit…
HappyKit provides NextJS applications with repetitive tasks (CRON tasks), very simple analytics, and feature flags. You can subscribe to the beta version here!
Benefits of using NextJS
NextJS is lightning fast!
Thanks to server-side rendering and static site generation, NextJS applications run significantly faster. Next takes care of the default performance optimizations.
Easy deployment process
Vercel (the company behind NextJS) makes it easy deploying full-stack React apps… A couple of mouse clicks and you have a professional deployment pipeline. It includes pre-deployment and production deployments.
NextJS provides routing
NextJS provides a quick and easy way to create APIs in applications. If your application uses third-party APIs, then you often need your own API for proxy requests and token storage. NextJS routing is perfect for this.
Easy to set up
NextJS lets you customize babel or webpack configurations. Adding webpack loaders or babel plugins is easy!
Disadvantages of using NextJS
NextJS is a stubborn (opinionated) framework
NextJS has only one way to work with routes, and you cannot customize it for yourself. NextJS is limited to its file-based route and dynamic routes are only possible when using a NodeJS server.
When should you use NextJS?
When creating a landing page
NextJS is great for creating landing pages and other marketing tasks.
When SEO Matters
When building e-commerce sites, search engine optimization is more important than ever. Thanks to server-side rendering, NextJS stands out in this regard as well.
When creating websites
Server-side rendering of the application eliminates the need for clients to render on their devices. For users of slower devices, this can result in faster boot times.
When should you use Create-React-App?
When creating a gated application
If your application is only accessible to authenticated users, it loses most of the benefits of server-side rendering. In this case, CSR applications work fine, they are easier and cheaper to host.
When building web applications
Web applications generally benefit less from server-side rendering. Typically, these applications are reused by users, and we can apply caching to provide lightning fast loading without the cost and hassle of SSR.
We hope this article helped you decide if NextJS and Create-React-App are right for your next project. Both of these tools are very cool for building React apps. You won’t be able to choose a winner: for some cases it is better to use NextJS, and for others – Create-React-App.