To get started, create an empty
tsconfig.json file in the root of your project:
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.jsonfile for you. You may customize this file.
next-env.d.tsfile, 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.