Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit b1153cb

Browse files
authored
docs: advise users of create-next-app --ts, --typescript (vercel#25349)
Since vercel#24655 landed in 10.2.1, I wanted to update the documentation, especially for the top Google results for "next typescript", so that users know how to create a TS project. Please feel free to change anything you feel is appropriate.
1 parent 77a6fef commit b1153cb

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

docs/api-reference/create-next-app.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ npx create-next-app
1212
yarn create next-app
1313
```
1414

15+
You can create a [TypeScript project](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md) with the `--ts, --typescript` flag:
16+
17+
```bash
18+
npx create-next-app --ts
19+
# or
20+
yarn create next-app --typescript
21+
```
22+
1523
### Options
1624

1725
`create-next-app` comes with the following options:
1826

27+
- **--ts, --typescript** - Initialize as a TypeScript project.
1928
- **-e, --example [name]|[github-url]** - An example to bootstrap the app with. You can use an example name from the [Next.js repo](https://github.com/vercel/next.js/tree/master/examples) or a GitHub URL. The URL can use any branch and/or subdirectory.
2029
- **--example-path [path-to-example]** - In a rare case, your GitHub URL might contain a branch name with a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar). In this case, you must specify the path to the example separately: `--example-path foo/bar`
2130
- **--use-npm** - Explicitly tell the CLI to bootstrap the app using npm. To bootstrap using yarn we recommend to run `yarn create next-app`

docs/basic-features/typescript.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@ description: Next.js supports TypeScript by default and has built-in types for p
1111
</ul>
1212
</details>
1313

14-
Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/) experience out of the box, similar to an IDE.
14+
Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/)
15+
experience out of the box, similar to an IDE.
1516

16-
To get started, create an empty `tsconfig.json` file in the root of your project:
17+
## `create-next-app` support
18+
19+
You can create a TypeScript project with [`create-next-app`](https://nextjs.org/docs/api-reference/create-next-app) using the `--ts, --typescript` flag like so:
20+
21+
```
22+
npx create-next-app --ts
23+
# or
24+
yarn create next-app --typescript
25+
```
26+
27+
## Existing projects
28+
29+
To get started in an existing project, create an empty `tsconfig.json` file in
30+
the root folder:
1731

1832
```bash
1933
touch tsconfig.json

packages/create-next-app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The easiest way to get started with Next.js is by using `create-next-app`. This
66
npx create-next-app
77
```
88

9+
Or, for a [TypeScript project](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md):
10+
11+
```bash
12+
npx create-next-app --typescript
13+
```
14+
915
To create a new app in a specific folder, you can send a name as an argument. For example, the following command will create a new Next.js app called `blog-app` in a folder with the same name:
1016

1117
```bash

0 commit comments

Comments
 (0)