Skip to content

mecograph/React-Umbraco-Example

 
 

Repository files navigation

Umbraco React Example Site

Live demo: http://umbraco-react.systempioneer.com/

Live demo screenshot

What is this?

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

Features

  • 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

Technical Overview

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.

Contributing

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):

  • Make the project a little easier to set up for new cloners
  • Distribute as an Umbraco package
  • The react code needs to be gone over to be refactored for readability
  • Let's write unit tests for the js and .NET

Special Thanks

License

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.

About

Umbraco React Example Site with Server Rendering

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.2%
  • HTML 12.5%
  • CSS 4.4%
  • Classic ASP 4.0%
  • C# 1.2%
  • XSLT 0.7%