Unverified Commit eddf5e0d authored by C. Lewis's avatar C. Lewis Committed by GitHub

docs: advise users of `create-next-app --ts, --typescript` (#25349)

Since #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. 
parent 5142c0e5
......@@ -12,10 +12,19 @@ npx create-next-app
yarn create next-app
```
You can create a [TypeScript project](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md) with the `--ts, --typescript` flag:
```bash
npx create-next-app --ts
# or
yarn create next-app --typescript
```
### Options
`create-next-app` comes with the following options:
- **--ts, --typescript** - Initialize as a TypeScript project.
- **-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.
- **--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`
- **--use-npm** - Explicitly tell the CLI to bootstrap the app using npm. To bootstrap using yarn we recommend to run `yarn create next-app`
......
......@@ -11,9 +11,23 @@ description: Next.js supports TypeScript by default and has built-in types for p
</ul>
</details>
Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/) experience out of the box, similar to an IDE.
Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/)
experience out of the box, similar to an IDE.
To get started, create an empty `tsconfig.json` file in the root of your project:
## `create-next-app` support
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:
```
npx create-next-app --ts
# or
yarn create next-app --typescript
```
## Existing projects
To get started in an existing project, create an empty `tsconfig.json` file in
the root folder:
```bash
touch tsconfig.json
......
......@@ -6,6 +6,12 @@ The easiest way to get started with Next.js is by using `create-next-app`. This
npx create-next-app
```
Or, for a [TypeScript project](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md):
```bash
npx create-next-app --typescript
```
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:
```bash
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment