14

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?

Abhishek Prajapati
  • 345
  • 1
  • 4
  • 15

2 Answers2

12

Me and my teacher came up with a neat little Stack for web dev. I call it NAPER:

  • N = NextJS (SSR and SSG)
  • A = ASP.Net (compiled based API written in C#)
  • P = PostgreSQL (relation DB)
  • E = EntityFramework (strong ORM for C#)
  • R = Redis (caching DB)

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.

Mathis Côté
  • 156
  • 1
  • 5
  • 1
    quick question, does the next-js app have to run on a different server than the api? usually host the react app as a static app (build output) and then it will connect to the net api via the browser calls – tHeSiD Jul 26 '22 at 11:33
  • 1
    NAPER... nice. That is where I am heading, I come from asp.net world and don't think you can beat a good c# solution for a properly architected backend. I use PostgreSQL but Dapper as a micro ORM. Glad to hear someone else on same page :) Do you use any next api functions or straight to .et api? – M H Aug 03 '22 at 19:33
  • @tHeSiD You can have both the NextJS project and the ASP.Net API on the same server. The NextJS will always call the ASP.Net API with HTTP Calls though, so you would not gain anything having them both on the same server except a small speed increase I think. – Mathis Côté Aug 15 '22 at 15:51
  • @MH Yeah C# is always a good pick for pretty much anything xD! I discovered NextJS/ReactJS with this small project, I don't use any NextJS API function since I go straight to the ASP.Net API. Maybe those functions could be useful for small changes not requiring the Database? – Mathis Côté Aug 15 '22 at 15:53
8

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.

nixn
  • 1,337
  • 3
  • 16
  • 33