Adding Typescript is very easy.
We start by installing Typescript globally and the type definitions for NodeJS and React for our project.
$ npm i -g typescript
$ npm i -D typescript @types/node @types/react
Then, we need to initialize Typescript in your project.
$ tsc --init
And finally we need to start our development server.
When NextJS sees our tsconfig.json
it will automatically add a new file named next-env.d.ts
on the root of our project and it will update our tsconfig.json
$ npm run dev
Thats it! 🎉
You can start renaming your js/jsx files to ts/tsx.