Server-Side Rendering with React

import React from 'react';

const App = React.createClass({
    displayName: 'App',

    propTypes: {
        headline: React.PropTypes.string.isRequired
    },

    render: function render() {
        return (
            

{this.props.headline}

); } }); export default App;

Hello World!

import express from 'express';
import exphbs from 'express-handlebars';
import React from 'react';
import ReactDOMServer from 'react-dom/server';

const app = express();

app.engine('hbs', exphbs({extname: '.hbs'}));
app.set('view engine', 'hbs');

app.use(express.static('public'));

app.get('/', (req, res) => {
    const state = { headline: 'Hello World!' };

    res.render('index', {
        app: ReactDOMServer.renderToString(),
        state: JSON.stringify(state)
    });
});