Carl Rippon

Building SPAs

Carl Rippon
BlogBooks / CoursesAbout
This site uses cookies. Click here to find out more

Why React with ASP.NET Core?

April 14, 2020
dotnetreact

ASP.NET Core is a great option for building the backend of a Single Page Application (SPA) today but what about the frontend? Angular has always been very popular in the .NET community and there is the new kid on the block as well, Blazor. So, why would we choose to use React for our frontend? Let’s find out …

Super robust

React is developed by a team at Facebook to power Facebook itself. New React versions are generally used within the Facebook product before they are released to the wider community. So, it will already have been used by millions of users and be nice and robust before we use it in our projects.

Backwards compatibility

If React introduces a breaking change, the migration costs hurt their own company. So, they put a lot of thought into backwards compatibility. If there is a breaking change, we always get a lot of advanced notice and very often there is a codemod that can be run on our code to make the required changes.

Open vision

The React team is very open with the developments they are working on and welcome feedback. Concurrent mode is a shining example of this - they have been talking to the community in the last year and taking on board feedback.

Huge ecosystem

React is very popular in comparison to angular and vuejs and its popularity continues to increase.

React v Angular v Vue

This has resulted in there being lots of robust supporting libraries for things like state management, UI components, and styling. There is lots of material available to help learn React as well.

There are also huge communities on Stack Overflow and Reddit ready to help if we get stuck. At the time of writing this article, 15,000 answers have been posted on React in the last couple of months versus only 428 Blazor answers in the same timeframe.

React doesn’t take over the whole frontend

You don’t have to use React to power the whole of your frontend. You can start with using React for a small piece of the frontend and then expand its use over time.

Easy to get started

There is a handy Visual Studio template to create projects that have an ASP.NET Core backend with a React frontend. There is even a template to include Redux as well!

This is a great way to explore and get started with using React with ASP.NET Core.

Static Typing with TypeScript

We are used to strongly-type code in the .NET world which helps us catch problems early. Statically typed languages, such as C#, also allow editors, such as Visual Studio, to provide productivity features search as IntelliSense, code refactoring and navigation.

JavaScript is a loosely typed language though. So, do we have to give up these benefits with React? Absolutely not! TypeScript adds a powerful and flexible type system to JavaScript and works beautifully with React.

Developers love React

React is the most loved web framework according to the Stack Overflow 2019 survey.

Developers have fallen in love with its component-driven approach to building user interfaces. The way that components are constructed and composed together with JSX is simple but powerful.

Wrap up

React is a great choice for building a frontend on an ASP.NET Core backend. It’s quick to get up and running, even when adding it to an existing non-React frontend. Facebook will ensure it will continue to develop and be well supported for many years to come. The React community is also massive. So, it’s never been a better time to give React a try!

If you to learn about using React with ASP.NET Core you might find my book useful:

ASP.NET Core 5 and React

ASP.NET Core 5 and React
Find out more

Want more content like this?

Subscribe to receive notifications on new blog posts and courses

Required
© Carl Rippon
Privacy Policy