|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: A JavaScript library for building user interfaces |
| 4 | +id: home |
| 5 | +--- |
| 6 | +<div class="hero"> |
| 7 | + <div class="wrap"> |
| 8 | + <div class="text"><strong>ReactJS.NET</strong></div> |
| 9 | + <div class="minitext"> |
| 10 | + React ♥ C# and ASP.NET MVC |
| 11 | + </div> |
| 12 | + </div> |
| 13 | +</div> |
| 14 | +<section class="content wrap"> |
| 15 | + <section class="home-section"> |
| 16 | + <p> |
| 17 | + ReactJS.NET makes it easier to use Facebook's |
| 18 | + [React](http://facebook.github.io/react/) and |
| 19 | + [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html) from C# and |
| 20 | + other .NET languages, focusing specifically on ASP.NET MVC (although it |
| 21 | + also works in other environments). It assumes you already know the basics |
| 22 | + of React and its usage. If not, check out the |
| 23 | + [React tutorial](http://facebook.github.io/react/docs/tutorial.html) first. |
| 24 | + </p> |
| 25 | + <div id="examples"> |
| 26 | + <div class="example"> |
| 27 | + <h3>On-the-fly [JSX to JavaScript compilation](/getting-started/usage.html)</h3> |
| 28 | + <div class="example-desc"> |
| 29 | + <p> |
| 30 | + Simply name your file with a `.jsx` extension and link to the |
| 31 | + file via a `script` tag. |
| 32 | + </p> |
| 33 | + <p> |
| 34 | + The files will automatically be compiled to JavaScript and cached |
| 35 | + server-side. No precompilation required. Perfect for development. |
| 36 | + </p> |
| 37 | + </div> |
| 38 | + <div class="example-code"> |
| 39 | + |
| 40 | +```javascript |
| 41 | +// /Scripts/HelloWorld.jsx |
| 42 | +var HelloWorld = React.createClass({ |
| 43 | + render: function() { |
| 44 | + return <div>Hello world!</div>; |
| 45 | + } |
| 46 | +}); |
| 47 | +``` |
| 48 | +```html |
| 49 | +<!-- Reference it from HTML --> |
| 50 | +<script src="@Url.Content("~/Scripts/HelloWorld.jsx")"></script> |
| 51 | +``` |
| 52 | +</div> |
| 53 | + </div> |
| 54 | + <div class="example"> |
| 55 | + <h3>JSX to JavaScript compilation via popular minification/combination libraries</h3> |
| 56 | + <div class="example-desc"> |
| 57 | + <p> |
| 58 | + Use Cassette or ASP.NET Minification and Combination? ReactJS.NET's |
| 59 | + got you covered. |
| 60 | + </p> |
| 61 | + <p> |
| 62 | + Reference your JSX files and they will be included in your bundles |
| 63 | + along with your other JavaScript files. |
| 64 | + </p> |
| 65 | + </div> |
| 66 | + <div class="example-code"> |
| 67 | + |
| 68 | +```csharp |
| 69 | +// In BundleConfig.cs |
| 70 | +bundles.Add(new JsxBundle("~/bundles/main").Include( |
| 71 | + // Add your JSX files here |
| 72 | + "~/Scripts/HelloWorld.jsx", |
| 73 | + "~/Scripts/AnythingElse.jsx", |
| 74 | + // You can include regular JavaScript files in the bundle too |
| 75 | + "~/Scripts/ajax.js", |
| 76 | +)); |
| 77 | +``` |
| 78 | +```html |
| 79 | +<!-- In your view --> |
| 80 | +@Scripts.Render("~/bundles/main") |
| 81 | +``` |
| 82 | +</div> |
| 83 | + </div> |
| 84 | + <div class="example"> |
| 85 | + <h3>[Server-side component rendering](http://reactjs.net/guides/server-side-rendering.html)</h3> |
| 86 | + <div class="example-desc"> |
| 87 | + <p> |
| 88 | + Pre-render the initial state of your React components server-side to |
| 89 | + make the initial load feel faster. |
| 90 | + </p> |
| 91 | + </div> |
| 92 | + <div class="example-code"> |
| 93 | + |
| 94 | +```html |
| 95 | +<!-- This will render the component server-side --> |
| 96 | +@Html.React("CommentsBox", new { |
| 97 | + initialComments = Model.Comments |
| 98 | +}) |
| 99 | + |
| 100 | +<!-- Initialise the component in JavaScript too --> |
| 101 | +<script src="http://fb.me/react-0.10.0.min.js"></script> |
| 102 | +@Scripts.Render("~/bundles/main") |
| 103 | +@Html.ReactInitJavaScript() |
| 104 | +``` |
| 105 | +</div> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + </section> |
| 109 | + <hr class="home-divider" /> |
| 110 | + <section class="home-bottom-section"> |
| 111 | + <div class="buttons-unit"> |
| 112 | + <a href="/download" class="button">Get Started</a> |
| 113 | + </div> |
| 114 | + </section> |
| 115 | +</section> |
0 commit comments