StackLite

How to setup a Next.js project with TypeScript?
78
I want to start a new Next.js project and I prefer using TypeScript. What is the recommended way to initialize a Next.js project with TypeScript support? Are there any specific configurations or best practices I should be aware of?
nextjs
typescript
react
setup

Suggested Tags (AI)

nextjs
typescript
react
Asked about 2 years ago
CHCharlie Brown

1 Answer

60
The easiest way is to use `create-next-app` with the TypeScript flag:

```bash
npx create-next-app@latest my-app --typescript
# or
yarn create next-app my-app --typescript
# or
pnpm create next-app my-app --typescript
```
This will set up a new Next.js project with TypeScript configured out of the box, including a `tsconfig.json` file.
answered about 2 years ago by
ALAlice Wonderland