You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-reference/next.config.js/basepath.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,14 @@ description: Learn more about setting a base path in Next.js
4
4
5
5
# Base Path
6
6
7
-
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
7
+
<details>
8
+
<summary><b>Version History</b></summary>
9
+
10
+
| Version | Changes |
11
+
| -------- | ---------------- |
12
+
|`v9.5.0`| Base Path added. |
13
+
14
+
</details>
8
15
9
16
To deploy a Next.js application under a sub-path of a domain you can use the `basePath` config option.
Copy file name to clipboardExpand all lines: docs/api-reference/next.config.js/headers.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,23 @@ description: Add custom HTTP headers to your Next.js app.
4
4
5
5
# Headers
6
6
7
-
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
Headers allow you to set custom HTTP headers for an incoming request path.
17
25
18
26
To set custom HTTP headers you can use the `headers` key in `next.config.js`:
@@ -173,8 +181,6 @@ module.exports = {
173
181
174
182
## Header, Cookie, and Query Matching
175
183
176
-
Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.
177
-
178
184
To only apply a header when either header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the header to be applied.
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L33).
47
+
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L68).
48
48
49
49
However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.
Copy file name to clipboardExpand all lines: docs/api-reference/next.config.js/redirects.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,23 @@ description: Add redirects to your Next.js app.
4
4
5
5
# Redirects
6
6
7
-
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
Redirects allow you to redirect an incoming request path to a different destination path.
17
25
18
26
Redirects are only available on the Node.js environment and do not affect client-side routing.
@@ -117,8 +125,6 @@ module.exports = {
117
125
118
126
## Header, Cookie, and Query Matching
119
127
120
-
Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.
121
-
122
128
To only match a redirect when header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the redirect to be applied.
Copy file name to clipboardExpand all lines: docs/api-reference/next.config.js/rewrites.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,27 @@ description: Add rewrites to your Next.js app.
4
4
5
5
# Rewrites
6
6
7
-
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
Rewrites allow you to map an incoming request path to a different destination path.
17
25
26
+
Rewrites act as a URL proxy and mask the destination path, making it appear the user hasn't changed their location on the site. In contrast, [redirects](/docs/api-reference/next.config.js/redirects.md) will reroute to a new page a show the URL changes.
27
+
18
28
Rewrites are only available on the Node.js environment and do not affect client-side routing.
19
29
20
30
To use rewrites you can use the `rewrites` key in `next.config.js`:
@@ -197,8 +207,6 @@ module.exports = {
197
207
198
208
## Header, Cookie, and Query Matching
199
209
200
-
Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.
201
-
202
210
To only match a rewrite when header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the rewrite to be applied.
203
211
204
212
`has` items have the following fields:
@@ -319,7 +327,7 @@ module.exports = {
319
327
}
320
328
```
321
329
322
-
See additional information on incremental adoption [in the docs here](https://nextjs.org/docs/migrating/incremental-adoption).
330
+
See additional information on incremental adoption [in the docs here](/docs/migrating/incremental-adoption.md).
Copy file name to clipboardExpand all lines: docs/api-reference/next.config.js/trailing-slash.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,14 @@ description: Configure Next.js pages to resolve with or without a trailing slash
4
4
5
5
# Trailing Slash
6
6
7
-
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
7
+
<details>
8
+
<summary><b>Version History</b></summary>
9
+
10
+
| Version | Changes |
11
+
| -------- | --------------------- |
12
+
|`v9.5.0`| Trailing Slash added. |
13
+
14
+
</details>
8
15
9
16
By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example `/about/` will redirect to `/about`. You can configure this behavior to act the opposite way, where urls without trailing slashes are redirected to their counterparts with trailing slashes.
Copy file name to clipboardExpand all lines: docs/api-reference/next/router.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ export default ActiveLink
41
41
42
42
The following is the definition of the `router` object returned by both [`useRouter`](#useRouter) and [`withRouter`](#withRouter):
43
43
44
-
-`pathname`: `String` - Current route. That is the path of the page in `/pages`
44
+
-`pathname`: `String` - Current route. That is the path of the page in `/pages`, the configured `basePath` or `locale` is not included.
45
45
-`query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching.md). Defaults to `{}`
46
46
-`asPath`: `String` - The path (including the query) shown in the browser without the configured `basePath` or `locale`.
47
47
-`isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/basic-features/data-fetching.md#fallback-pages).
@@ -74,6 +74,7 @@ router.push(url, as, options)
74
74
-`options` - Optional object with the following configuration options:
75
75
-`scroll` - Optional boolean, controls scrolling to the top of the page after navigation. Defaults to `true`
76
76
-[`shallow`](/docs/routing/shallow-routing.md): Update the path of the current page without rerunning [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation), [`getServerSideProps`](/docs/basic-features/data-fetching.md#getserversideprops-server-side-rendering) or [`getInitialProps`](/docs/api-reference/data-fetching/getInitialProps.md). Defaults to `false`
77
+
-`locale` - Optional string, indicates locale of the new page
77
78
78
79
> You don't need to use `router.push` for external URLs. [window.location](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) is better suited for those cases.
Copy file name to clipboardExpand all lines: docs/api-routes/response-helpers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ export default function handler(req, res) {
23
23
The included helpers are:
24
24
25
25
-`res.status(code)` - A function to set the status code. `code` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
26
-
-`res.json(json)` - Sends a JSON response. `json` must be a valid JSON object
26
+
-`res.json(body)` - Sends a JSON response. `body` must be a [serialiazable object](https://developer.mozilla.org/en-US/docs/Glossary/Serialization)
27
27
-`res.send(body)` - Sends the HTTP response. `body` can be a `string`, an `object` or a `Buffer`
28
28
-`res.redirect([status,] path)` - Redirects to a specified path or URL. `status` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). If not specified, `status` defaults to "307" "Temporary redirect".
0 commit comments