rsnext/examples/custom-server-typescript
Joe Haddad b3170d2648
Format missed files (#7464)
* Format missed files

* Remove unnecessary rule

* Fix type error
2019-05-29 18:19:32 -07:00
..
pages Format missed files (#7464) 2019-05-29 18:19:32 -07:00
server Move syntax formatting to prettier (#7454) 2019-05-29 13:57:26 +02:00
.babelrc Update typescript examples to use 1.0.1 of next-typescript (#4472) 2018-05-25 11:28:35 +02:00
.gitignore [custom-server-typescript] fixed custom server build issues (#7385) 2019-05-23 14:08:03 -05:00
next.config.js Add custom-server-typescript example (see #3694) (#3838) 2018-02-22 16:29:47 +01:00
nodemon.json Move syntax formatting to prettier (#7454) 2019-05-29 13:57:26 +02:00
package.json [custom-server-typescript] fixed custom server build issues (#7385) 2019-05-23 14:08:03 -05:00
README.md [custom-server-typescript] fixed custom server build issues (#7385) 2019-05-23 14:08:03 -05:00
tsconfig.json [custom-server-typescript] fixed custom server build issues (#7385) 2019-05-23 14:08:03 -05:00
tsconfig.server.json [custom-server-typescript] fixed custom server build issues (#7385) 2019-05-23 14:08:03 -05:00

Custom server with TypeScript + Nodemon example

How to use

Using create-next-app

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

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

Download manually

Download the example:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/custom-server-typescript
cd custom-server-typescript

Install it and run:

npm install
npm run dev
# or
yarn
yarn dev

Deploy it to the cloud with now (download)

now

The idea behind the example

The example shows how you can use TypeScript on both the server and the client while using Nodemon to live reload the server code without affecting the Next.js universal code.

Server entry point is server/index.ts in development and dist/index.js in production. The second directory should be added to .gitignore.