This article was originally posted on my personal blog.
There is an official NextJS guide on how to create a custom server. However, it only works with JavaScript. Please follow their guide and come back.
Rename
server.js
toserver.ts
.Update the
scripts
inpackage.json
"scripts": {
"dev": "ts-node server.ts",
"build": "next build",
"start": "NODE_ENV=production ts-node server.ts"
}
- Install
ts-node
yarn add ts-node
- Add this section in
tsconfig.json
{
// ...
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"module": "commonjs"
}
}
}
Top comments (3)
And? Wtf? Is that all?
Loool. Really worked. Thanks!
Awesome 🔥