To get started, create an empty tsconfig.json
file in the root of your project:
touch tsconfig.json
Now, try starting the development server if not already running (npm run dev
or yarn dev
). Next.js will automatically detect TypeScript usage and install the required packages with the following message:
It looks like you're trying to use TypeScript but do not have the required package(s) installed. Installing dependencies
During this step Next.js also:
tsconfig.json
file for you. You may customize this file.next-env.d.ts
file, which ensures Next.js types are picked up by the TypeScript compiler. You should not touch this file.You can now use TypeScript for your Next.js app. Let's talk about how to convert your Next.js app into TypeScript.