I'm trying to figure out the difference between NextJs and Create React App. I know both are there to make our life easier while developing our Front-end Apps using ReactJs.
After exploring some articles on Google, I found that the main difference is
NextJs provides server side rendering (SSR) while Create React App provides client side rendering (CSR) and SSR improves performance of Application Loading.
But what about other parameters from development perspective like
Maintainability and Scalability of the Web App developed with NextJS or CRA?
Typescript and React Hooks/Redux support?
Or you can even Guide me if I'm doing a wrong comparison?
The correct comparison is Next JS vs Create React App (CRA). Create React App (CRA) is a de facto way to bootstrap new React applications. However, Create React App gives plain vanilla React setup with minimal functionality. Whereas Next JS provides much more out of the box.
Next JS is a framework that holds React on its base, while React JS is an open-source JavaScript library, developed and maintained by Facebook. Next JS is used to create web applications and performs server-side rendering, whereas React JS focuses on rendering towards the DOM.
Next. js was created on top of React in an effort to build an easy-to-use development framework. It was developed by Vercel (formerly Zeit) and makes use of many of the popular features of React. Right out of the box, Next.
Create React App is just a React project creation engine to help you setup your React project quickly. After running the CRA script npx create-react-app <appname>
you will get a nice and clean single-page application that you can run. Under the hood you also get things like babel, eslint, jest, webpack already setup so it's a really convenient way to start doing React development. And in case you'd need more control over the configuration of those tools, you can still use npm run eject
.
Next.js on the other hand is a framework based on React to build Node.js server-side apps. This means you will use the same component-oriented logic to build pages and leverage the Next.js routing engine for page to page navigation. Server-side rendering will allow loading time to be more spread over time, so perceived performance will be probably better. Redux can be used as well but there will be some additional steps to make it work properly (see https://github.com/kirill-konshin/next-redux-wrapper)
Whatever you choose, in the end, it will be React coding. Components, JSX, TypeScript support, React hooks, and all other core aspects of React will be supported either way. Therefore, you can expect similar degree of maintainability. On the other hand, scalability depends on your choice: if you choose Next.js you will host the app on a server infrastructure which should be sized according to your audience whereas React bundle created with CRA just need to be statically hosted somewhere.
I've used both NextJs and CRA. Both these frameworks can be used to get started quickly and provide a good developer experience. However, both of these have use cases where either of them shines better. I'll try to compare them based on some of these factors. Feel free to suggest edits with additional points or comments
CRA | Next.js |
---|---|
CRA doesn't support SSR out of the box. However, you can still configure it. It just takes more effort to setup SSR with your preferred server and configuration. The development team doesn't have plans to support this in the near future. They suggest other tools for this use case. | NextJs has different types for SSR. It supports SSR out of the box. * Static generation: fetch data at build time. This works best for use cases like blogs or static websites * Server side rendering: fetch data and render for each requests. You have to do this when you need to serve different view for different users. |
I think this is point where these tools are very different and your decision can depend on this factor
CRA | Next.js |
---|---|
Create React App doesn't leave you a lot of room to configure it. Configurations like webpack config cannot be changed unless you stray away from normal CRA way (eject, rescripts, rewired, craco). Basically, you have to use what's configured in react-scripts which is the core of CRA. | Almost everything is configurable. If you check the example NextJs templates, you can see files like babelrc , jest.config , eslintrc etc that you can configure. |
CRA | Next.js |
---|---|
CRA is very opinionated. If you keep updated with the releases of CRA, it's not hard to maintain. | NextJs is also well maintained. They release regular updates. |
CRA | Next.js |
---|---|
Supports out of the box. You can initialize CRA app with typescript with npx create-react-app my-app --template typescript | Supports typescript out of the box. Start with configurations for typescript with touch tsconfig.json |
Latest version of both CRA and NextJs installs a version of React that supports hooks. You can also upgrade to the latest version easily
Redux is a library that you can use with both these tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With