title: express.Router() vs express() in express
body: <p>As mentioned in express <a href="https://expressjs.com/en/guide/routing.html#express-router" rel="noreferrer">routing guide</a> and <a href="https://stackoverflow.com/a/36734383/109747">this answer</a>, we can create "mini-app" and <code>use</code> it from the main app. However I saw a code where it uses <code>app</code> instead of <code>router</code> in the module</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var express = require('express');
  var userRoutes = require('./routes/user');
  
  var app = express();
  
  app.use('/user', userRoutes);
  
  module.exports = app;
  </code></pre>
  
  <p><strong>routes/user.js</strong></p>
  
  <pre><code>var express = require('express');
  var app = express(); // not express.Router() !!
  
  app.get('/:name', function(req, res) {
    var userName = req.params.name;
    res.render('user.jade', {
      userName: userName
    });
  });
  
  module.exports = app;
  </code></pre>
  
  <p>I assumed the correct usage in <code>routes/user.js</code> should be </p>
  
  <pre><code>router = express.Router()
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>app = express()
  </code></pre>
  
  <p>but <code>app = express()</code> also works! what are the differences and why <code>router = express.Router()</code> is better?</p>