title: How to dynamically render/load pages in express?
body: <p>I need to dynamically load/render part of a page in nodejs (v1.8.15) with express (>3.0) framework. Generally, I want to create a single-page app.</p>
  
  <p>I have a menu at the top of the page with links. Clicking on the links will change the content below, as in AJAX page loading.</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;home|login|signup|chat
  ..content for home..
  </code></pre>
  
  <p>If I press the 'signup' link:</p>
  
  <pre><code>home|login|&gt;signup|chat
  ..content for signup..
  </code></pre>
  
  <p>In express I have routes on the server:</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  app.get('/signup', function(req, res) {
      // render signup.jade
      res.render('signup');
  }
  app.post('/signup', function(req, res) {
      // .. work with information
      if (ok) res.send('ok', 200); else res.send(error, 200);
  }
  </code></pre>
  
  <p>After reading <a href="http://blog.nodejitsu.com/single-page-apps-with-nodejs" rel="noreferrer">this</a>, I figured out that I should use socket.io. I know sockets well, so it will be easy to send data about 'clicking on link' from the client to the server.</p>
  
  <p><strong>Q1: How do I render/load pages dynamically like I wrote in express?</strong></p>
  
  <p>Yes, I could use AJAX for page loading, but will it work for <code>.post</code> methods in express?
  How should I organize my thoughts to create such a site?</p>
  
  <p>By the way, I've read about <a href="http://derbyjs.com/" rel="noreferrer">Derby</a> and <a href="http://socketstream.org/" rel="noreferrer">SocketStream</a>, but I didn't understand.</p>
  
  <p><strong>Q2: Can I use Derby or SocketStream in my aims (site functions: login, signup, chat)? How?</strong></p>
  
  <p>If SocketStream is what I need, that would be very bad, because Heroku doesn't work with it.</p>