Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Next.js 15 updates #65603

Merged
merged 70 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a64971c
Add PPR page
delbaoliveira May 9, 2024
a03ba9b
Reorder rendering section
delbaoliveira May 9, 2024
f02dbf9
Clean up, use consistent `experimental` titles
delbaoliveira May 9, 2024
8f09765
Document experimental_ppr
delbaoliveira May 9, 2024
f8d7b3b
Update ppr next.config.js page
delbaoliveira May 9, 2024
79b8b2b
Document unstable_after
delbaoliveira May 9, 2024
513c610
Add package bundling page
delbaoliveira May 10, 2024
66db9a2
Clean up, fix broken links
delbaoliveira May 10, 2024
c8da54f
Broken links
delbaoliveira May 10, 2024
20a8384
Missing p
delbaoliveira May 10, 2024
1748791
Fix links
delbaoliveira May 10, 2024
afb0d5d
Fix server actions example
delbaoliveira May 10, 2024
fae8c7e
Update mentions of `useFormStatus`
delbaoliveira May 10, 2024
827bce7
Review useOptimistic example
delbaoliveira May 10, 2024
13e7542
Review server actions page
delbaoliveira May 10, 2024
365fec4
Apply suggestions from code review
delbaoliveira May 10, 2024
abe69e2
Update docs/02-app/01-building-your-application/03-rendering/01-parti…
delbaoliveira May 10, 2024
75b92d7
`fetch` rework
delbaoliveira May 14, 2024
81eb834
Revamp caching and revalidating sections
delbaoliveira May 14, 2024
37e5f4c
Merge branch 'canary' into docs-iusd
manovotny May 20, 2024
68e6e55
Add React Compiler docs
delbaoliveira May 21, 2024
1b4b2a4
Apply suggestions from code review
delbaoliveira May 21, 2024
db58642
Apply package bundling feedback, add version history
delbaoliveira May 21, 2024
4b4a7b3
Merge branch 'docs-iusd' of https://github.com/vercel/next.js into do…
delbaoliveira May 21, 2024
161ed38
Add v15 upgrade guide (wip)
delbaoliveira May 21, 2024
a4ada6a
PPR polish
delbaoliveira May 21, 2024
cf6dc83
Update fetch api docs
delbaoliveira May 21, 2024
fd0dc91
Revamp data fetching section (wip)
delbaoliveira May 21, 2024
327b1bc
update Data Cache and Client-side Router cache doc section
StephDietz May 21, 2024
6d212a5
Update docs/02-app/02-api-reference/04-functions/unstable_after.mdx
anthonyshew May 21, 2024
61e7a2d
Update docs/02-app/01-building-your-application/02-data-fetching/01-f…
anthonyshew May 21, 2024
0c68ef0
Update docs/02-app/01-building-your-application/02-data-fetching/01-f…
anthonyshew May 21, 2024
57f3689
update route handler docs
StephDietz May 21, 2024
3097485
Update docs/02-app/01-building-your-application/02-data-fetching/01-f…
anthonyshew May 21, 2024
e266fd7
Update docs/02-app/01-building-your-application/02-data-fetching/01-f…
anthonyshew May 21, 2024
b20a69d
Update docs/02-app/01-building-your-application/02-data-fetching/01-f…
anthonyshew May 21, 2024
7457a83
Merge branch 'docs-iusd' of https://github.com/vercel/next.js into do…
StephDietz May 21, 2024
d4f7f83
First batch of broken links.
anthonyshew May 21, 2024
f360451
Merge branch 'canary' into docs-iusd
StephDietz May 21, 2024
13617ae
Merge branch 'docs-iusd' of https://github.com/vercel/next.js into do…
anthonyshew May 21, 2024
1810717
First batch of broken links.
anthonyshew May 21, 2024
b540554
Undo sanity example.
anthonyshew May 21, 2024
642aaba
Second batch of broken links.
anthonyshew May 21, 2024
00a170d
More broken links.
anthonyshew May 21, 2024
96dcc67
Testing link...
anthonyshew May 21, 2024
ccce593
Bring it back.
anthonyshew May 21, 2024
4b652ea
Move it to separate lines?
anthonyshew May 21, 2024
fa08dbb
Maybe...?
anthonyshew May 21, 2024
7d36013
This is right?
anthonyshew May 21, 2024
2c04502
lmao
anthonyshew May 21, 2024
8a32697
Update docs/02-app/02-api-reference/05-next-config-js/ppr.mdx
manovotny May 22, 2024
4ae5aa2
Merge branch 'canary' into docs-iusd
delbaoliveira May 22, 2024
2876f00
Review route handlers docs
delbaoliveira May 22, 2024
9d11925
Rework client-side router cache docs
delbaoliveira May 22, 2024
2299916
Add note for fetchCache = 'default-cache' for root layout
delbaoliveira May 22, 2024
0e7e013
fix `after` import
ztanner May 22, 2024
641f705
Condense good to know
manovotny May 23, 2024
03f91f4
Apply suggestions from code review
manovotny May 23, 2024
4434f72
Update docs/02-app/01-building-your-application/02-data-fetching/03-s…
manovotny May 23, 2024
e442464
Split package.json and gitignore sentenses
manovotny May 23, 2024
85f45d6
Adds Tailwind globals
manovotny May 23, 2024
b4f89c6
reword
manovotny May 23, 2024
378ae0b
React compiler
manovotny May 23, 2024
1531fe9
Valid root layout
manovotny May 23, 2024
17720eb
Explicit update commands
manovotny May 23, 2024
d4b0f85
Update upgrade guide and metadata
delbaoliveira May 23, 2024
78b0471
speed insights
manovotny May 23, 2024
f840fc0
Update rc command
manovotny May 23, 2024
0c8fc2f
fix "before" blocks for serverComponentsExternalPackages & bundlePage…
ztanner May 23, 2024
4007608
lint
ztanner May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,11 @@ See the [`<Link>` API reference](/docs/app/api-reference/components/link) for mo

### 3. Caching

Next.js has an **in-memory client-side cache** called the [Router Cache](/docs/app/building-your-application/caching#router-cache). As users navigate around the app, the React Server Component Payload of [prefetched](#2-prefetching) route segments and visited routes are stored in the cache.
Next.js has an **in-memory client-side cache** called the [Router Cache](/docs/app/building-your-application/caching#client-side-router-cache). As users navigate around the app, the React Server Component Payload of [prefetched](#2-prefetching) route segments and visited routes are stored in the cache.

This means on navigation, the cache is reused as much as possible, instead of making a new request to the server - improving performance by reducing the number of requests and data transferred.

Learn more about how the [Router Cache](/docs/app/building-your-application/caching#router-cache) works and how to configure it.
Learn more about how the [Router Cache](/docs/app/building-your-application/caching#client-side-router-cache) works and how to configure it.

### 4. Partial Rendering

Expand All @@ -396,7 +396,7 @@ Browsers perform a "hard navigation" when navigating between pages. The Next.js

### 6. Back and Forward Navigation

By default, Next.js will maintain the scroll position for backwards and forwards navigation, and re-use route segments in the [Router Cache](/docs/app/building-your-application/caching#router-cache).
By default, Next.js will maintain the scroll position for backwards and forwards navigation, and re-use route segments in the [Router Cache](/docs/app/building-your-application/caching#client-side-router-cache).

### 7. Routing between `pages/` and `app/`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,24 @@ export async function GET(request: Request) {}
export async function GET(request) {}
```

Route Handlers can be nested inside the `app` directory, similar to `page.js` and `layout.js`. But there **cannot** be a `route.js` file at the same route segment level as `page.js`.
Route Handlers can be nested anywhere inside the `app` directory, similar to `page.js` and `layout.js`. But there **cannot** be a `route.js` file at the same route segment level as `page.js`.

### Supported HTTP Methods

The following [HTTP methods](https://developer.mozilla.org/docs/Web/HTTP/Methods) are supported: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, and `OPTIONS`. If an unsupported method is called, Next.js will return a `405 Method Not Allowed` response.

### Extended `NextRequest` and `NextResponse` APIs

In addition to supporting native [Request](https://developer.mozilla.org/docs/Web/API/Request) and [Response](https://developer.mozilla.org/docs/Web/API/Response). Next.js extends them with
[`NextRequest`](/docs/app/api-reference/functions/next-request) and [`NextResponse`](/docs/app/api-reference/functions/next-response) to provide convenient helpers for advanced use cases.
In addition to supporting the native [Request](https://developer.mozilla.org/docs/Web/API/Request) and [Response](https://developer.mozilla.org/docs/Web/API/Response) APIs, Next.js extends them with [`NextRequest`](/docs/app/api-reference/functions/next-request) and [`NextResponse`](/docs/app/api-reference/functions/next-response) to provide convenient helpers for advanced use cases.

## Behavior

### Caching

Route Handlers are dynamic by default as of Next.js v15. To opt-in to caching for `GET` requests, you can use the following config:
Route Handlers are not cached by default. You can, however, opt into caching for `GET` methods. To do so, use a [route config option](/docs/app/api-reference/file-conventions/route-segment-config#dynamic) such as `export const dynamic = 'force-static'` in your Route Handler file.

```ts filename="app/items/route.ts" switcher
// opt in to caching the route handler
export const dynamic = 'force-static' // or 'error'
export const dynamic = 'force-static'

export async function GET() {
const res = await fetch('https://data.mongodb-api.com/...', {
Expand All @@ -67,6 +65,8 @@ export async function GET() {
```

```js filename="app/items/route.js" switcher
export const dynamic = 'force-static'

export async function GET() {
const res = await fetch('https://data.mongodb-api.com/...', {
headers: {
Expand All @@ -80,7 +80,9 @@ export async function GET() {
}
```

> **TypeScript Warning:** `Response.json()` is only valid from TypeScript 5.2. If you use a lower TypeScript version, you can use [`NextResponse.json()`](/docs/app/api-reference/functions/next-response#json) for typed responses instead.
### Special Route Handlers

Special Route Handlers like [`sitemap.ts`](/docs/app/api-reference/file-conventions/metadata/sitemap), [`opengraph-image.tsx`](/docs/app/api-reference/file-conventions/metadata/opengraph-image), and [`icon.tsx`](/docs/app/api-reference/file-conventions/metadata/app-icons), and other [metadata files](/docs/app/api-reference/file-conventions/metadata) remain static by default unless they use dynamic functions or dynamic config options.

### Route Resolution

Expand Down Expand Up @@ -113,7 +115,7 @@ The following examples show how to combine Route Handlers with other Next.js API

### Revalidating Cached Data

You can [revalidate cached data](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) using the [`next.revalidate`](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) option:
You can [revalidate cached data](/docs/app/building-your-application/data-fetching/caching-and-revalidating#revalidating-data) using the [`next.revalidate`](/docs/app/building-your-application/data-fetching/caching-and-revalidating#revalidating-data) option:

```ts filename="app/items/route.ts" switcher
export async function GET() {
Expand Down

This file was deleted.

Loading