Next.js - Set up with TypeScript
Learn how to integrate TypeScript to your Next.js project
Steps
Create
tsconfig.json
Install the required packages
Converting files from
.js
to.tsx
1. Create an empty tsconfig.json
file in the root of your project:
tsconfig.json
file in the root of your project:touch tsconfig.json
2. Install the required packages
yarn add --dev typescript @types/react @types/react-dom @types/node
A file named next-env.d.ts
will be created in the root of your project. This file ensures Next.js types are picked up by the TypeScript compiler. You cannot remove it, however, you can edit it (but you don't need to).
Last updated
Was this helpful?