rsnext/examples/custom-server
2020-08-30 06:53:29 +00:00
..
pages chore: Remove react redundant imports on examples (#13169) 2020-05-22 17:37:09 +02:00
.gitignore Added .gitignore to examples that are deployed to vercel (#15127) 2020-07-16 10:52:23 -04:00
package.json Add cross-env to ensure examples work on Windows 10 (#16694) 2020-08-30 06:53:29 +00:00
README.md Simplify example usage instructions (#16678) 2020-08-29 22:22:02 -04:00
server.js Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00

Custom server example

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 so you can customize as much as you want.

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.

How to use

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example custom-server custom-server-app
# or
yarn create next-app --example custom-server custom-server-app