Share via

Adding React.Js components to my existing/new Asp.net MVC core 6.0 , is this possible/compatible?

Prasad 20 Reputation points
2024-01-28T19:44:47.3666667+00:00

I am building ASP.NET Core 6.0 with MVC web application, and I am using these technologies...

  1. Web API
  2. Entity Framework
  3. SQL Server
  4. Razor views, JavaScript, JQuery & Bootstrap.
  5. Apexcharts

But i want to improve my MVC web application front-end by utilizing React.JS..
So my question is that is it possible? and if so how i can do?

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

Developer technologies | ASP.NET Core | Other
Developer technologies | ASP.NET Core | ASP.NET API

Answer accepted by question author

Konstantinos Passadis 19,696 Reputation points MVP
2024-01-28T20:51:47.6566667+00:00

Hello @Prasad !

Yes it is possible and of course you can do it !

https://learn.microsoft.com/en-us/aspnet/core/client-side/spa/react?view=aspnetcore-8.0&tabs=visual-studio

React.js can coexist with Razor views and can be used to handle more dynamic and complex user interfaces within your ASP.NET Core application

https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-react?view=vs-2022

Currently, Visual Studio includes ASP.NET Core Single Page Application (SPA) templates that support Angular and React. The templates provide a built-in Client App folder in your ASP.NET Core projects that contains the base files and folders of each framework.

You can use the method described in this article to create ASP.NET Core Single Page Applications that:

Put the client app in a separate project, outside from the ASP.NET Core project

Create the client project based on the framework CLI installed on your computer
```--

I hope this helps !

*The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription*

**Kindly mark the answer as Accepted and Upvote in case it helped or post your feedback to help !**
Regards

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 84,061 Reputation points
    2024-01-29T17:35:51.1866667+00:00

    MVC code supports react. there is a template to build a react spa application, but this template uses the obsolete react_scripts for the react build chain.

    your main decision will be the javascript build tool chain to convert the jsx files to javascript and add module support. Webpack, parcel and vite are the most popular choices. as typescript also supports react jsx, you can just use the visual studio typescript support, even if you just use vanilla javascript.

    also if you want to use react without build tools, there are libraries to replace .jsx parsing:

    https://dev.to/dperrymorrow/using-react-without-jsx-no-build-14gg

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.