How can I pass data from express server to react views?
<p>I have a simple express server with a connection to a orientdb database.
I need to pass information from express to react views.
For example, in express I have:</p>

<pre><code>router.get('/', function(req, res, next) {
  Vertex.getFromClass('Post').then(
    function (posts) {
      res.render('index', { title: 'express' });
    }
  );
});
</code></pre>

<p>So, in this example, I need to have in my react index component, the <code>posts</code> variable to set the state of the componenent. (I'm using react only in the frontend, not server-side)</p>

<pre><code>class IndexPage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      posts: []
    };
  }

  render() {
    return (
      &lt;div&gt;
        &lt;Posts posts={posts} /&gt;
      &lt;/div&gt;
    );
  }
}
</code></pre>

<p>How can I get the posts in react from express?</p>

<p>I found that maybe I can do an ajax request from react, but I think that that isn't the best way.</p>

<p>If I need to get that posts in a real time way, using socket.io for example, what are the differences?</p>

<p>PD: In express I have the possibility to use some template engine like handlebars or hogan. Can this template engines help in this topic?</p>

<p>Thanks!!!</p>