Skip to content

Commit

Permalink
Merge branch 'canary' into wbinnssmith/git-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Aug 29, 2023
2 parents 607cc87 + 540f8e2 commit 8e7a3d7
Show file tree
Hide file tree
Showing 290 changed files with 30,763 additions and 1,034 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages/next/bundles/** -text
packages/next/compiled/** -text
packages/next/bundles/** -text linguist-vendored
packages/next/compiled/** -text linguist-vendored

# Make next/src/build folder indexable for github search
build/** linguist-generated=false
8 changes: 8 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ jobs:
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}

- name: Cache on ${{ github.ref_name }}
uses: ijjk/rust-cache@turbo-cache-v1.0.7
with:
shared-key: build-${{ matrix.settings.target }}
save-if: 'true'
cache-provider: 'turbo'

# we only need custom caching for docker builds
# as they are on an older Node.js version and have
# issues with turbo caching
Expand Down Expand Up @@ -528,6 +535,7 @@ jobs:
- uses: ./.github/actions/next-stats-action
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
NEXT_SKIP_NATIVE_POSTINSTALL: 1

upload_turbopack_bytesize:
name: Upload Turbopack Bytesize trace to Datadog
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ on:
required: false
description: 'if test trace needs uploading'
type: string
rustCacheKey:
required: false
description: 'rustCacheKey to cache shared target assets'
type: string

env:
NAPI_CLI_VERSION: 2.14.7
Expand Down Expand Up @@ -114,6 +118,14 @@ jobs:

- run: corepack prepare --activate yarn@1.22.19 && npm i -g "turbo@${TURBO_VERSION}" "@napi-rs/cli@${NAPI_CLI_VERSION}"

- name: Cache on ${{ github.ref_name }}
uses: ijjk/rust-cache@turbo-cache-v1.0.7
if: ${{ inputs.rustCacheKey }}
with:
shared-key: ${{ inputs.rustCacheKey }}-x86_64-unknown-linux-gnu
save-if: ${{ github.ref_name == 'canary' }}
cache-provider: 'turbo'

# clean up any previous artifacts to avoid hitting disk space limits
- run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target

Expand Down
4 changes: 2 additions & 2 deletions bench/nested-deps-app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "bench-nested-deps-app-router",
"scripts": {
"prepare-bench": "rimraf components && fuzzponent -d 2 -s 206 -o components",
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"dev-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"build-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next build",
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next start",
"dev-nocache": "rimraf .next && pnpm dev",
"dev-nocache": "rimraf .next && pnpm dev-application",
"dev-cpuprofile-nocache": "rimraf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 node --cpu-prof ../../node_modules/next/dist/bin/next",
"build-nocache": "rimraf .next && pnpm build-application"
},
Expand Down
4 changes: 2 additions & 2 deletions bench/nested-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "bench-nested-deps",
"scripts": {
"prepare-bench": "rimraf components && fuzzponent -d 2 -s 206 -o components",
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"dev-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"build-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next build",
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next start",
"dev-nocache": "rimraf .next && pnpm dev",
"dev-nocache": "rimraf .next && pnpm dev-application",
"dev-cpuprofile-nocache": "rimraf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 node --cpu-prof ../../node_modules/next/dist/bin/next",
"build-nocache": "rimraf .next && pnpm build-application"
},
Expand Down
1 change: 0 additions & 1 deletion bench/readdir/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions bench/readdir/create-fixtures.sh

This file was deleted.

24 changes: 0 additions & 24 deletions bench/readdir/glob.js

This file was deleted.

21 changes: 0 additions & 21 deletions bench/readdir/recursive-readdir.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export async function GET(request, { params }) {

### Streaming

Streaming is commonly used in combination with Large Language Models (LLMs), such an OpenAI, for AI-generated content. Learn more about the [AI SDK](https://sdk.vercel.ai/docs).
Streaming is commonly used in combination with Large Language Models (LLMs), such as OpenAI, for AI-generated content. Learn more about the [AI SDK](https://sdk.vercel.ai/docs).

```ts filename="app/api/chat/route.ts" switcher
import { Configuration, OpenAIApi } from 'openai-edge'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ If you have multiple fetch requests in a statically rendered route, and each has

Learn more about [time-based revalidation](/docs/app/building-your-application/caching#time-based-revalidation).

> **Good to know:** Revalidation only works with the [Node.js runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes#nodejs-runtime) (default).
#### On-demand Revalidation

Data can be revalidated on-demand by path ([`revalidatePath`](/docs/app/api-reference/functions/revalidatePath)) or by cache tag ([`revalidateTag`](/docs/app/api-reference/functions/revalidateTag)) inside a Route Handler or a Server Action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { revalidatePath } from 'next/cache'

export default async function submit() {
await submitForm()
revalidatePath('/')
}
```

Or invalidate a specific data fetch with a cache tag using [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag):

```ts filename="app/actions.ts" switcher
Expand All @@ -198,6 +209,17 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { revalidateTag } from 'next/cache'

export default async function submit() {
await addPost()
revalidateTag('posts')
}
```

</AppOnly>

### Redirecting
Expand Down Expand Up @@ -244,6 +266,19 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { redirect } from 'next/navigation'
import { revalidateTag } from 'next/cache'

export default async function submit() {
const id = await addPost()
revalidateTag('posts') // Update cached posts
redirect(`/post/${id}`) // Navigate to new route
}
```

</AppOnly>

### Form Validation
Expand Down Expand Up @@ -740,7 +775,18 @@ You can set cookies inside a Server Action using the [`cookies`](/docs/app/api-r
import { cookies } from 'next/headers'

export async function create() {
const cart = await createCart():
const cart = await createCart()
cookies().set('cartId', cart.id)
}
```

```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
const cart = await createCart()
cookies().set('cartId', cart.id)
}
```
Expand Down Expand Up @@ -789,6 +835,17 @@ export async function create() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
const auth = cookies().get('authorization')?.value
// ...
}
```
</AppOnly>
### Deleting Cookies
Expand Down Expand Up @@ -833,6 +890,17 @@ export async function create() {
}
```
```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
cookies().delete('name')
// ...
}
```
See [additional examples](/docs/app/api-reference/functions/cookies#deleting-cookies) for deleting cookies from Server Actions.
</AppOnly>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ There are many considerations to make when choosing a runtime. This table shows
| Security | Normal | High | High |
| Latency | Normal | Low | Lowest |
| npm Packages | All | All | A smaller subset |
| Revalidation | Yes | Yes | No |
| [Static Rendering](/docs/app/building-your-application/rendering/server-components#static-rendering-default) | Yes | Yes | No |
| [Dynamic Rendering](/docs/app/building-your-application/rendering/server-components#dynamic-rendering) | Yes | Yes | Yes |
| [Data Revalidation w/ `fetch`](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) | Yes | Yes | Yes |

### Edge Runtime

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ See the [`cookies`](/docs/app/api-reference/functions/cookies) API reference.

### Segment Config Options

The Route Segment Config options can be used override the route segment defaults or when you're not able to use the `fetch` API (e.g. database client or 3rd party libraries).
The Route Segment Config options can be used to override the route segment defaults or when you're not able to use the `fetch` API (e.g. database client or 3rd party libraries).

The following Route Segment Config options will opt out of the Data Cache and Full Route Cache:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Props = {

export async function generateMetadata(
{ params, searchParams }: Props,
parent?: ResolvingMetadata
parent: ResolvingMetadata
): Promise<Metadata> {
// read route params
const id = params.id
Expand Down
58 changes: 58 additions & 0 deletions docs/02-app/02-api-reference/04-functions/permanentRedirect.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: permanentRedirect
description: API Reference for the permanentRedirect function.
---

The `permanentRedirect` function allows you to redirect the user to another URL. `permanentRedirect` can be used in Server Components, Client Components, [Route Handlers](/docs/app/building-your-application/routing/route-handlers), and [Server Actions](/docs/app/building-your-application/data-fetching/forms-and-mutations).

When used in a streaming context, this will insert a meta tag to emit the redirect on the client side. Otherwise, it will serve a 308 (Permanent) HTTP redirect response to the caller.

If a resource doesn't exist, you can use the [`notFound` function](/docs/app/api-reference/functions/not-found) instead.

> **Good to know**: If you prefer to return a 307 (Temporary) HTTP redirect instead of 308 (Permanent), you can use the [`redirect` function](/docs/app/api-reference/functions/redirect) instead.
## Parameters

The `permanentRedirect` function accepts two arguments:

```js
permanentRedirect(path, type)
```

| Parameter | Type | Description |
| --------- | ------------------------------------------------------------- | ----------------------------------------------------------- |
| `path` | `string` | The URL to redirect to. Can be a relative or absolute path. |
| `type` | `'replace'` (default) or `'push'` (default in Server Actions) | The type of redirect to perform. |

By default, `permanentRedirect` will use `push` (adding a new entry to the browser history stack) in [Server Actions](/docs/app/building-your-application/data-fetching/forms-and-mutations) and `replace` (replacing the current URL in the browser history stack) everywhere else. You can override this behavior by specifying the `type` parameter.

The `type` parameter has no effect when used in Server Components.

## Returns

`permanentRedirect` does not return any value.

## Example

Invoking the `permanentRedirect()` function throws a `NEXT_REDIRECT` error and terminates rendering of the route segment in which it was thrown.

```jsx filename="app/team/[id]/page.js"
import { permanentRedirect } from 'next/navigation'

async function fetchTeam(id) {
const res = await fetch('https://...')
if (!res.ok) return undefined
return res.json()
}

export default async function Profile({ params }) {
const team = await fetchTeam(params.id)
if (!team) {
permanentRedirect('/login')
}

// ...
}
```

> **Good to know**: `permanentRedirect` does not require you to use `return permanentRedirect()` as it uses the TypeScript [`never`](https://www.typescriptlang.org/docs/handbook/2/functions.html#never) type.
4 changes: 4 additions & 0 deletions docs/02-app/02-api-reference/04-functions/redirect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ description: API Reference for the redirect function.

The `redirect` function allows you to redirect the user to another URL. `redirect` can be used in Server Components, Client Components, [Route Handlers](/docs/app/building-your-application/routing/route-handlers), and [Server Actions](/docs/app/building-your-application/data-fetching/forms-and-mutations).

When used in a streaming context, this will insert a meta tag to emit the redirect on the client side. Otherwise, it will serve a 307 HTTP redirect response to the caller.

If a resource doesn't exist, you can use the [`notFound` function](/docs/app/api-reference/functions/not-found) instead.

> **Good to know**: If you prefer to return a 308 (Permanent) HTTP redirect instead of 307 (Temporary), you can use the [`permanentRedirect` function](/docs/app/api-reference/functions/permanentRedirect) instead.
## Parameters

The `redirect` function accepts two arguments:
Expand Down
Loading

0 comments on commit 8e7a3d7

Please sign in to comment.