diff --git a/docs/api-reference/create-next-app.md b/docs/api-reference/create-next-app.md index 273bd9d8c236e..6163ce0c90230 100644 --- a/docs/api-reference/create-next-app.md +++ b/docs/api-reference/create-next-app.md @@ -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` diff --git a/docs/basic-features/typescript.md b/docs/basic-features/typescript.md index 51116dd6259c3..2dcee6912d9b0 100644 --- a/docs/basic-features/typescript.md +++ b/docs/basic-features/typescript.md @@ -11,9 +11,23 @@ description: Next.js supports TypeScript by default and has built-in types for p -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 diff --git a/packages/create-next-app/README.md b/packages/create-next-app/README.md index 8e629058467a3..0c95055ef6d01 100644 --- a/packages/create-next-app/README.md +++ b/packages/create-next-app/README.md @@ -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