Skip to content

Commit 516b282

Browse files
authored
Docs/getting started improv (#82741)
Part of: https://linear.app/vercel/issue/DOC-4809/layout-pages-and-linking-and-navigating-improvements Iterating a bunch of improvements to getting-started
1 parent 62f9611 commit 516b282

File tree

2 files changed

+76
-21
lines changed

2 files changed

+76
-21
lines changed

docs/01-app/01-getting-started/01-installation.mdx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,52 @@ description: Learn how to create a new Next.js application with the `create-next
55

66
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
77

8+
<AppOnly>
9+
10+
Create a new Next.js app and run it locally.
11+
12+
## Quick start
13+
14+
1. Create a new Next.js app named `my-app`
15+
2. `cd my-app` and start the dev server.
16+
3. Visit `http://localhost:3000`.
17+
18+
```bash package="pnpm"
19+
pnpm create next-app@latest my-app --yes
20+
cd my-app
21+
pnpm dev
22+
```
23+
24+
```bash package="npm"
25+
npx create-next-app@latest my-app --yes
26+
cd my-app
27+
npm run dev
28+
```
29+
30+
```bash package="yarn"
31+
yarn create next-app@latest my-app --yes
32+
cd my-app
33+
yarn dev
34+
```
35+
36+
```bash package="bun"
37+
bun create next-app@latest my-app --yes
38+
cd my-app
39+
bun dev
40+
```
41+
42+
- `--yes` skips prompts using saved preferences or defaults. The default setup enables TypeScript, Tailwind, App Router, and Turbopack, with import alias `@/*`.
43+
44+
</AppOnly>
45+
846
## System requirements
947

1048
Before you begin, make sure your system meets the following requirements:
1149

1250
- [Node.js 18.18](https://nodejs.org/) or later.
1351
- macOS, Windows (including WSL), or Linux.
1452

15-
## Automatic installation
53+
## Create with the CLI
1654

1755
The quickest way to create a new Next.js app is using [`create-next-app`](/docs/app/api-reference/cli/create-next-app), which sets up everything automatically for you. To create a project, run:
1856

docs/01-app/01-getting-started/02-project-structure.mdx

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Top-level files are used to configure your application, manage dependencies, run
5252

5353
### Routing Files
5454

55+
Add `page` to expose a route, `layout` for shared UI such as header, nav, or footer, `loading` for skeletons, `error` for error boundaries and `route` for APIs.
56+
5557
| | | |
5658
| ----------------------------------------------------------------------------- | ------------------- | ---------------------------- |
5759
| [`layout`](/docs/app/api-reference/file-conventions/layout) | `.js` `.jsx` `.tsx` | Layout |
@@ -66,35 +68,50 @@ Top-level files are used to configure your application, manage dependencies, run
6668

6769
### Nested routes
6870

69-
| | |
70-
| --------------- | -------------------- |
71-
| `folder` | Route segment |
72-
| `folder/folder` | Nested route segment |
71+
Folders define URL segments. Nesting folders nests segments. Layouts at any level wrap their child segments. A route becomes public when a `page` or `route` file exists.
72+
73+
| Path | URL pattern | Notes |
74+
| --------------------------- | --------------- | ----------------------------- |
75+
| `app/layout.tsx` || Root layout wraps all routes |
76+
| `app/blog/layout.tsx` || Wraps `/blog` and descendants |
77+
| `app/page.tsx` | `/` | Public route |
78+
| `app/blog/page.tsx` | `/blog` | Public route |
79+
| `app/blog/authors/page.tsx` | `/blog/authors` | Public route |
7380

7481
### Dynamic routes
7582

76-
| | |
77-
| ------------------------------------------------------------------------------------------------------ | -------------------------------- |
78-
| [`[folder]`](/docs/app/api-reference/file-conventions/dynamic-routes#convention) | Dynamic route segment |
79-
| [`[...folder]`](/docs/app/api-reference/file-conventions/dynamic-routes#catch-all-segments) | Catch-all route segment |
80-
| [`[[...folder]]`](/docs/app/api-reference/file-conventions/dynamic-routes#optional-catch-all-segments) | Optional catch-all route segment |
83+
Parameterize segments with square brackets. Use `[segment]` for a single param, `[...segment]` for catch‑all, and `[[...segment]]` for optional catch‑all. Access values via the [`params`](/docs/app/api-reference/file-conventions/page#params-optional) prop.
84+
85+
| Path | URL pattern |
86+
| ------------------------------- | -------------------------------------------------------------------- |
87+
| `app/blog/[slug]/page.tsx` | `/blog/my-first-post` |
88+
| `app/shop/[...slug]/page.tsx` | `/shop/clothing/shoes`, `/shop/clothing/shirts` |
89+
| `app/docs/[[...slug]]/page.tsx` | `/docs`, `/docs/layouts-and-pages`, `/docs/api-reference/use-router` |
8190

8291
### Route Groups and private folders
8392

84-
| | |
85-
| ------------------------------------------------------------------------------ | ------------------------------------------------ |
86-
| [`(folder)`](/docs/app/api-reference/file-conventions/route-groups#convention) | Group routes without affecting routing |
87-
| [`_folder`](#private-folders) | Opt folder and all child segments out of routing |
93+
Organize code without changing URLs with route groups [`(group)`](/docs/app/api-reference/file-conventions/route-groups#convention), and colocate non-routable files with private folders [`_folder`](#private-folders).
94+
95+
| Path | URL pattern | Notes |
96+
| ------------------------------- | ----------- | ----------------------------------------- |
97+
| `app/(marketing)/page.tsx` | `/` | Group omitted from URL |
98+
| `app/(shop)/cart/page.tsx` | `/cart` | Share layouts within `(shop)` |
99+
| `app/blog/_components/Post.tsx` || Not routable; safe place for UI utilities |
100+
| `app/blog/_lib/data.ts` || Not routable; safe place for utils |
88101

89102
### Parallel and Intercepted Routes
90103

91-
| | |
92-
| ------------------------------------------------------------------------------------------- | -------------------------- |
93-
| [`@folder`](/docs/app/api-reference/file-conventions/parallel-routes#slots) | Named slot |
94-
| [`(.)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept same level |
95-
| [`(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept one level above |
96-
| [`(..)(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept two levels above |
97-
| [`(...)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept from root |
104+
These features fit specific UI patterns, such as slot-based layouts or modal routing.
105+
106+
Use `@slot` for named slots rendered by a parent layout. Use intercept patterns to render another route inside the current layout without changing the URL, for example, to show a details view as a modal over a list.
107+
108+
| Pattern (docs) | Meaning | Typical use case |
109+
| ------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------ |
110+
| [`@folder`](/docs/app/api-reference/file-conventions/parallel-routes#slots) | Named slot | Sidebar + main content |
111+
| [`(.)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept same level | Preview sibling route in a modal |
112+
| [`(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept parent | Open parent child as overlay |
113+
| [`(..)(..)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept two levels | Deeply nested overlay |
114+
| [`(...)folder`](/docs/app/api-reference/file-conventions/intercepting-routes#convention) | Intercept from root | Show arbitrary route in current view |
98115

99116
### Metadata file conventions
100117

0 commit comments

Comments
 (0)