score:154
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
server side rendering
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. |
configurability
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. |
maintainability
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. |
typescript
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 |
hooks support
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 support
redux is a library that you can use with both these tools.
score:-1
react is a javascript library while next js is a framework that builds up on react and greatly enhances react apps and makes building large scale react apps easier, the main advantages of next js are the build-in server-side rendering (ssr) wich automatically pre-renders your page on the server and makes your app run much faster ssr also helps with seo optimization the next key feature is also its build-in file-based routing whereas in react you'd have to install the react router package and manually add the routes, next js also can be used as a backend where you can blend your backend and react code in the same project without having to create an api ,since it can do ssr it can also perform server-side code like store data, get data, authentication etc. personally i think next js is a very powerful tool that every react developer should master.
score:5
react is just a javascript library, and on the other hand, nextjs is a react framework. ssr is one of the benefits of nextjs, but there are many other benefits. nextjs can do everything react does, and on top of that, it has features that react alone doesn't have. checkout the documentation for nextjs here: https://nextjs.org/docs/getting-started
score:9
tldr
biggest difference is purpose of both projects. nextjs : jam stack or static site generator create react app : is an officially supported way to create single-page react applications.
explanation:
this conundrum is true for many opensource projects. seem alternative of other but they have key differences. for example in this case although both projects use reactjs as front end and produce webapps. the problem they solve are very distinct. there are some overlapping features themes/templates in js. but development and future work will be to enhance project such that it helps solve there problem statement in better way.
i.e. nextjs will try to include if there are any new markdown features developed. which won't be the case in createreactapps.
suggestion.
from your question it seems you are looking these projects for developing react native apps. so i will suggest go with create react app.
your comparison should primarily be whether this project align with problem i am solving. then compare. maintainability, scalability, typescript and react hooks/redux support.
in case needed more info do comment.
score:50
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.
Source: stackoverflow.com
Related Query
- What is the difference between NextJs and Create React App
- What is the difference between React Native and React?
- What is the difference between hashHistory and browserHistory in react router?
- React Native - What is the difference between StyleSheet.absoluteFill() and StyleSheet.absoluteFillObject()?
- What is the main difference between React Query and Redux?
- React - What is the difference between renderToString and renderToStaticMarkup
- React Hooks: What is the difference between 'useMutationEffect' and 'useLayoutEffect'?
- What is the difference between React component instance property and state property?
- What is the difference between React component and React component instance?
- How does React router works and what is the difference between <link> and<Route>
- What is the difference between arrow functions and regular functions inside React functional components (no longer using class components)?
- ES6 React - What are the difference between reference, shallow copy and deep copy and how to compare them?
- What is the difference between useHistory() and props.history in React Route
- what is the difference between getDefaultProps and getInitialState react js
- React Transition Group: What is the difference between the appear, enter, exit events and the enter, active done className suffixes?
- What is the difference between accessible, accessibilityLabel and accessibilityHint properties of Text component in react native?
- What is the real difference between value and defaultValue in React JS?
- What is the difference between a javascript package, node package, and react package?
- What is the difference between React and Preact diff algorithm in depth
- What is the difference between a fibre object in React 16 and a React Element?
- What is the difference between Routing in React and Express
- What is the difference between passing a function name in onclick react and calling it through callback
- What is the difference between key and id in React component?
- what is the difference between React setState and Hooks setState?
- What's the difference between functional component and create component using useMemo() in React
- what is the difference between element attribute and component attribute in React <Route><Route/> tag
- What is the difference between function and functional React component?
- What is the difference between Nav.Link vs Link vs NavLink in react router DOM and react bootstrap?
- What is the difference between App: React.FunctionComponent and App = (): React.FunctionComponent?
- In React, what is the difference between using functional component and just a function, which returns React node?
More Query from same tag
- Trying to iterate over a nested object from an API and return the data into my react component
- uncontrolled <select> default value in ReactJS
- Error: write EIO error while yarn install of CRA application
- React component not rendering also not showing up
- Error adding image with react and webpack
- active class in react js
- Redirecting to home page after login conflicts with removing protected routes for logged in users | React
- Change URL when scroll into sections
- How do I change the change the color inside the iframe - React
- Textarea component which shows the count of written characters in React updates the value only after reload
- History not accessible from react-router-modal
- Error handling Google Place Api. If the api key is restricted input becomes blank
- (React) Redux state not filitering
- How to Fix Unhandled Rejection (TypeError): chat.setUser is not a function in Firechat by Firebase in React.js
- React js - fetch API - TypeError: ticker.map is not a function
- error in react.js when clicking npm start
- get data from server using axios with react
- Cant Resolve Installed Npm Module
- React - Update controlled element that has a default value
- how can i use global style when develop component library using styled-components
- React a component is changing an uncontrolled input of type checkbox to be controlled
- How to resolve the error from a promise in reactjs
- React toDoApp removing a task functionality not working
- Overriding material-ui styles
- There is a way to load main.js last react
- how to jest test an async action with axios in react?
- Not able to prepare my MERN app for deployment
- Why can't I install react/icons package?
- Redux: request into success or error flow from Component (using redux-saga)
- import scss from create react library package