···11+[](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/custom-server-express)
22+33+# Custom Express Server example
44+55+## How to use
66+77+### Using `create-next-app`
88+99+Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
1010+1111+```bash
1212+npx create-next-app --example custom-server-express custom-server-express-app
1313+# or
1414+yarn create next-app --example custom-server-express custom-server-express-app
1515+```
1616+1717+### Download manually
1818+1919+Download the example:
2020+2121+```bash
2222+curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/custom-server-express
2323+cd custom-server-express
2424+```
2525+2626+Install it and run:
2727+2828+```bash
2929+npm install
3030+npm run dev
3131+# or
3232+yarn
3333+yarn dev
3434+```
3535+3636+Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
3737+3838+```bash
3939+now
4040+```
4141+4242+## The idea behind the example
4343+4444+Most of the times the default Next server will be enough but sometimes you want to run your own server to customize routes or other kind of the app behavior. Next provides a [Custom server and routing](https://github.com/zeit/next.js#custom-server-and-routing) so you can customize as much as you want.
4545+4646+Because the Next.js server is just a node.js module you can combine it with any other part of the node.js ecosystem. in this case we are using express to build a custom router on top of Next.
4747+4848+The example shows a server that serves the component living in `pages/a.js` when the route `/b` is requested and `pages/b.js` when the route `/a` is accessed. This is obviously a non-standard routing strategy. You can see how this custom routing is being made inside `server.js`.