I am looking into React framework Next.js to see if it is best match as SPA for my next application where ASP.NET Core will be backend. I have used create-react-app
in the past so wanted to compare Next.js
with it. Our aim is not Server Side Rendering(SSR)
. Our project will be admin kind of project and SEO does not really matter. We will need performance for sure. We cannot use Static Generation as well as we need to load latest data for every page. We will need redux too.
The main benefits I read about Next.js are:
- SSR
- File Routing
- Full stack Dev – can use backend(Node.JS) with it
From these mentioned feature, File Routing will only be useful for us I believe as we don’t need other features for our project. Further more, I cannot see any component life cycle events. Can we still use it with Next.js?
Can anyone please highlight other benefits of using Next.js? And is it worth to use Next.js
over create-react-app
?
2
Answers
I have used nextjs in small projects, in one big production environment and some basic marketing sites within the past three years.
Where nextjs excels is at the examples folder and community. For most use cases you will find an example that does the job before hitting up the community.
For me nextjs is kind of the golden hammer for web. I roll with a lot less third party libs as most general features come with it. Router, Image, Compression, Dynamic Import, basic Backend..
I don’t like Deployment overheads in small teams. I can create a Marketing site with several SSG rendered landingpages for SEO, a SPA Client dashboard, a SPA Admin dashboard, SSR Blogpages… all within one project – one deployment. On the other side I would need for each SPA an CRA instance, nginx and maybe WordPress. But if your Admin Project doesn’t come along with this kind of „standards“ I would suggest working with CRA.
Recently my coworker who is managing the backend had no time to provide an API for newsletter subscribers, it was no big deal because I was able to create it myself with their API Routes, no extra Setup – created a folder, file & done.
To sum up, if you know react you know next. If you want the extra features you will have to learn them. In return you will get flexibility.
A: Component lifecycles are still implemented through react itself.
Me and my teacher came up with a neat little Stack for web dev. I call it NAPER:
This stack lets us use NextJS SSR/SSG features with a an ASP.Net API. The NextJS "API" is used as a proxy for the ASP.Net API.