Is it best to use Next.js along with ASP.NET Core web api if SSR is not the target?
Asked Answered
T

2

15

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?

Tiepolo answered 14/7, 2021 at 3:13 Comment(4)
You can use any language as backend.Iover
Yes, but main question is, is it best to use Next.js over create-react-app for my requirements mentioned above?Tiepolo
I don't know why you wanted to use next js if it's features is not required.Iover
I am just wanted to know if there are any key benefits I am missing/overlooking? That's it mate. I need to choose between Next.js and create-react-app so just need to get inputs from community if someone has used and can share their experience.Tiepolo
E
9

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.

Exoergic answered 18/7, 2021 at 20:3 Comment(0)
A
13

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.

Abbotsen answered 4/6, 2022 at 3:17 Comment(4)
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 callsSwing
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?Jacindajacinta
@Swing 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.Fourhanded
@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?Fourhanded
E
9

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.

Exoergic answered 18/7, 2021 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.