Live demo: http://umbraco-react.systempioneer.com/
This is the default Umbraco Fanoe starter kit re-imagined as a badass single-page app, powered by React. It's an example of how Umbraco and React can come together beautifully.
Built with love for our Umbraco friends by the dev team at SystemPioneer
- React components are rendered server-side within the Umbraco pipeline
- Content is rendered by Umbraco grid, you can edit content in the backoffice just like a regular Umbraco site
- Use of ES6 syntax & a build pipeline will be immediately familiar to React developers
- Bundled with Webpack with 90% code re-use between server and client bundles
Disclaimer: This is new project and shouldn't be used yet for production. It's unstable and APIs will change
Incoming requests are handled by a custom RenderMvcController, which is registered as the default controller and always renders the Master.cshtml template. In that template React server rendering is achieved using Reactjs.NET. An initial state for the React app is constructed using UmbracoHelper
and passed as a prop to the root component.
On the client side we use react-router and construct route handlers programatically, using what we know about the Umbraco content nodes from the initial state. Every route renders a ContentPage component, which uses the fetch api to make a request to a custom SurfaceController called RenderContentController. RenderContentController returns a JSON object containing a "Content" property, which is HTML rendererd by Umbraco and is used by React to update the page. It also returns a "Name" property which is used by react-helmet to update the page title.
We're definitely open for PRs! The project maintainer doesn't sleep and can merge a PR anytime. This is a new project and was built quickly as a proof-of-concept. There's a lot of hacky code and we want to refactor everything.
Still to do (at least):
- Refactor logic out of the Master view
- The ViewFromContentId method is referenced in a hacky way in the Master template, and should probably go in the service layer
- The react code needs to be gone over to be refactored for readability
- Let's write unit tests for the js and .NET
Copyright 2017 SYSTEMPIONEER LIMITED
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.