Maxi Zipitría

Maxi Zipitría

Writter of code, player of songs, VR enthusiast and apparently a blogger now

Setup Typescript on your NextJS project

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.

Maxi's profile picture

Hey! Thanks for reading, I hope you found it useful.

Feedback is always appreaciate it. If you have any send it to
maxi.zipitria@gmail.com

← Take me back