Search code examples
reactjsnext.jsroutesreact-router-dom

What is the Relation between React Js and Next Js


How does Next.js simplify the process of routing and data fetching compared to React.js

Using react-router-dom to create routes in react. While just creating folders for routes in Next js was much simpler. Does it make the routing faster or does it simplify the routing process.


Solution

  • Next JS is a framework that you write react code in. NextJS handles a lot more stuff with routing and allows you to develop your backend (which is nodejs not react) all in one code base which you couldn't do with just react. Next JS is a full stack framework that allows you to write both frontend and backend code in one project. The frontend framework that NextJs uses is react.

    Base on your edit: When using react router dom you are really just loading 1 page and changing what is shown (this is slightly untrue now with server components) With next JS you are actually rendering pages. For a long time you could not get any SEO with react ( this again is slightly untrue with server components) if you wanted to have SEO you needed to use nextJS because it was actually rendering different HTML pages to the DOM while react was using the shadow DOM