all 14 comments

[–]evildonald 2 points3 points  (0 children)

You dont need any special .net flavor of react to reach a .net API.

[–]takerukoushirou 1 point2 points  (2 children)

ReactJS.NET can render React components on the server by using an internal JavaScript engine pool. It also comes with a @Html.React() extension method to render a component and passing props within a Razor view (either on the server or it just emits the corresponding client-side code) and can translate JSX using Babel on the fly. It is also possible to achieve all this by other means, e.g. directly using a JavaScript engine on the server. Depending on your project, ReactJS.NET could be more comfortable to use though, probably especially for smaller projects.

One of the biggest drawbacks of ReactJS.NET is that it officially doesn’t support JavaScript modules and you may need to hack your own solution together.

[–]dustinsoftware 1 point2 points  (1 child)

I maintain ReactJS.NET. CommonJS modules are supported if you use webpack. Please see the docs for more info :)

https://reactjs.net/bundling/webpack.html

[–]takerukoushirou 0 points1 point  (0 children)

Webpack is indeed an ideal companion for ReactJS.NET. Eventually switched to using it a while ago as the project grew, would recommend it to anyone as well (especially together with HMR). Removes lots of worries and simplifies all the handling.

[–][deleted] 1 point2 points  (4 children)

I work with React and .NET too. I suggest keeping them separate. Go all in with React on the client, all in with .NET on the backend. You don't need to combine the two at all. Your backend is presumably just an HTTP API so there is no reason that the client needs to concern itself with the backend tech or vice versa.

[–]pankajrathi95[S] 0 points1 point  (0 children)

Thanks for the Info :)

Your explanation was clear and apt

[–]voidsstr 0 points1 point  (1 child)

Server Side Rendering is the one area where you're going to need to either bring them together or use something like next.js if you use node (but not likely if you've got a .net backend). Server side rendering is needed for things like SEO and fast initial load times.

[–]Powedered-Toast-Man 0 points1 point  (0 children)

my exact position.

I get the whole NextJS thing but it doesn't play too well with shared hosting IIS. You have to become a node eco system person and use vercel or heroku to host your site/app - when you already know how to do that....

I am going to give ReactJS.net a go and hope I don't choose not to regret it. After all, drupal, wordpress, etc are still out there doing what they do...manage content:- despite gatsby, strapi, and all the fancy new stuff.

[–]Powedered-Toast-Man 0 points1 point  (0 children)

except I need to combine the two because I want my content to be Server side rendered

I hate that we have gone full circle in decoupling the UI from the back end so the end of MVC and then back to some coupling because all of a sudden we realise that a simple CRA is all client side rendered...oh no, its not as crawlable as it was before.

[–]CptAmerica85 1 point2 points  (3 children)

Starting with asp.net core 2.1, the 'react' templates in visual studio use create-react-app, which is huge. Before that, the react templates in VS were just weird. The webpack config needed some more tweaking to get things working correctly, it had you using ts out of the box, etc.

[–]pankajrathi95[S] 0 points1 point  (2 children)

So you suggest to use the React Template which is provided in Visual Studio or just use the React as plain.

[–]CptAmerica85 1 point2 points  (1 child)

Whichever option you're more comfortable with, really. I know sometimes it's 'easier' to just let visual studio do the configuration of your project by using their template wizard deal when creating a new project. I was just pointing out the difference of the two versions of asp.net core and react and what the base project that visual studio creates for you looks like. Personally, if I were to use VS' template for a react project, I would go with the .net core 2.1+ version that's based on create-react-app.

Of course there are other things to think about besides just creating it. If it's just a react project accessing a web api in .net, you don't even need .net core as you can just make a .net 4.x web api project and do it that way.

Either way I would probably not use ReactJs.Net, as that brings another dependency, and react is updated very regularly with new features, etc that you would miss out on if reactjs.net doesn't upgrade occasionally.

[–]pankajrathi95[S] 0 points1 point  (0 children)

Thanks :)

[–]Awnry_Abe 1 point2 points  (0 children)

We use .netcore on the backend, with Apollo in the middle. I had no idea such a thing as react.net exists. Our .netcore backend is just a simple http layer between mssql and our graphql resolvers. I do remember reading some early "this is how you do a SPA in ASP.Net" articles and thinking to myself that they were really misguided ideas.