Skip to content
.NET library for JSX compilation and server-side rendering of React components
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create ISSUE_TEMPLATE.md Feb 9, 2019
site Add 5.0.0 blog post Jul 18, 2019
src Clean up references to source link package (#871) Jul 17, 2019
tests Enable HtmlHelperExtensionTests for .NET Core Jul 14, 2019
tools Add .NETCore 3 preview support (#791) Jun 4, 2019
tutorial-code Update dependency React.AspNet to v5.0.0 Jul 18, 2019
webhooks Update dependency Microsoft.NET.Sdk.Functions to v1.0.29 Jun 14, 2019
.editorconfig Enforce consistent line endings Jan 20, 2018
.gitattributes Enforce consistent line endings Jan 20, 2018
.gitignore Remove generated files Mar 15, 2019
.gitmodules Switch to @pauldotknopf's VroomJs fork rather than maintaining our own. Oct 1, 2016
LICENSE Switch to MIT license (same as React) (#621) Nov 5, 2018
README.md Docs: Add more details about server-rendering to readme Jun 11, 2019
azure-pipelines.yml Fix azure pipelines release builds (#832) Jun 10, 2019
build.proj 5.0.0 Jul 18, 2019
dev-build-push.bat Added all three VS 2017 versions to all build scripts (#610) Oct 17, 2018
dev-build.bat Added all three VS 2017 versions to all build scripts (#610) Oct 17, 2018
global.json Add .NETCore 3 preview support (#791) Jun 4, 2019
netlify.toml Add some missing redirects Nov 14, 2018
release-build-push.bat Added all three VS 2017 versions to all build scripts (#610) Oct 17, 2018
release-build.bat Added all three VS 2017 versions to all build scripts (#610) Oct 17, 2018
renovate.json Update Renovate to automerge patch versions Jun 15, 2019
runs-msbuild.bat minor comment changes Jun 7, 2019

README.md

ReactJS.NET

ReactJS.NET is a library that makes it easier to use Babel along with Facebook's React and JSX from C#.

Build status  NuGet version Download count

Features

Quick Start

Install the package

Install-Package React.Web.Mvc4 # For ASP.NET MVC 4 or 5
Install-Package React.AspNet   # For ASP.NET Core MVC

Install a Javascript engine and configure as the default (more info here on how this works)

Install-Package JavaScriptEngineSwitcher.V8
Install-Package JavaScriptEngineSwitcher.V8.Native.win-x64
public static class ReactConfig
{
    public static void Configure()
    {
        ReactSiteConfiguration.Configuration
            .AddScript("~/Content/HelloWorld.jsx");

        JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;
        JsEngineSwitcher.Current.EngineFactories.AddV8();
    }
}

Create JSX files

// /Scripts/HelloWorld.jsx
const HelloWorld = props => {
	return <div>Hello {props.greeting}</div>;
};

Reference the JSX files from your HTML

<!-- Place this where you want the component div to render -->
@Html.React("HelloWorld", new { Greeting = "friends!" });

<!-- Place these at the end of the page -->
<script src="@Url.Content("~/Scripts/HelloWorld.jsx")"></script>
@Html.ReactInitJavaScript();

Now you can use the HelloWorld component.

For information on more advanced topics (including precompilation and server-side rendering), check out the documentation

Building Manually and Contributing

When building your own copy of ReactJS.NET (for example, if implementing a new feature or fixing a bug), your first build always needs to be done using the build script (dev-build.bat) as this generates a few files required by the build (such as SharedAssemblyVersionInfo.cs). Once this build is completed, you can open React.sln in Visual Studio and compile directly from Visual Studio. Please refer to the documentation page on contributing for more information on contributing to ReactJS.NET.

Note that the build requires you to have Git installed. If you do not want to install Git, you may remove the GitVersion task from build.proj.

You can’t perform that action at this time.