I have developed an application using React + redux + EJS (with server side rendering) and its running fine in production. I have configured SSR + redux and all the code splitting stuff using webpack config. I have also implemented custom cache middleware to cache the SSR rendered html string ( as needed).
Now, I have been told to refactor the code to suit next.js framework and was wondering the real need for that. What are the main advantages of using next.js if I have already figured out a way to do SSR without next.js framework?
I am not just asking an opinion rather I am trying to understand the real pros/cons of next.js (if any) over CRA.
I have uploaded the boiler plate here if anyone needed a reference: https://github.com/bbest123/reactreduxssr
js does not work without server-side rendering (SSR) by default. I preferred using a non-SSR solution like Create React App, when my app did not require SSR, because SSR had caused me so many unnecessary problems. Turns out Next is still 💯/💯, even if you only need index.
Should I Use Next JS or CRA? Typically if you have an application that will only be used behind a login, CRA is a good choice. However, if you have an application for which SEO is important and fast page loads are critical, then Next JS is the right solution.
The answer is no. You would be better off using some kind of query library like swr or react-query to manage the API data. So why would you fetch data and store it in the Redux store when you can get awesome features like caching and pre-fetching all without using Redux?
Next. js is a React framework built by Vercel (formerly Zeit) to make server-side rendering (SSR) easier for React applications regardless of where your data comes from. Next. js also supports static exporting and, newly, incremental static regeneration.
The only con (kind of) I can think of using Next.js is that it's opinionated. It would require you to structure things in a certain way which IMO is still quite extensible.
Link
and prefetching capabilities)All these things said, if you've already built your solution without Next.js
and it works fine for your usecase, IMO there isn't a need to migrate to Next unless you are interested in abstracting some of the configurations and workings of SSR (which Next.js
would take care of).
One of Nextjs' best features is huge list of 70+ list of implementation examples representing almost every combination of CSS framework, store (flux/redux/mobx/graphQL) framework, node servers, etc.
It is possible to build a react SSR solution without Next.js, but the clean hooks
for server-side logic (getInitialProps
, pages/app.js
, etc ...) are what makes Next.js a top choice here. Next.js shines here by allowing you to write clean, maintainable, and Performant SSR web applications.
Lastly, the development team & community is amazing!
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