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/advanced-features/i18n-routing.md
+26-17Lines changed: 26 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -234,6 +234,30 @@ Next.js doesn't know about variants of a page so it's up to you to add the `href
234
234
235
235
> Note that Internationalized Routing does not integrate with [`next export`](/docs/advanced-features/static-html-export.md) as `next export` does not leverage the Next.js routing layer. Hybrid Next.js applications that do not use `next export` are fully supported.
236
236
237
+
### Dynamic Routes and `getStaticProps` Pages
238
+
239
+
For pages using `getStaticProps` with [Dynamic Routes](/docs/routing/dynamic-routes.md), all locale variants of the page desired to be prerendered need to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching.md#getstaticpaths-static-generation). Along with the `params` object returned for `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
240
+
241
+
```js
242
+
// pages/blog/[slug].js
243
+
exportconstgetStaticPaths= ({ locales }) => {
244
+
return {
245
+
paths: [
246
+
// if no `locale` is provided only the defaultLocale will be generated
247
+
{ params: { slug:'post-1' }, locale:'en-US' },
248
+
{ params: { slug:'post-1' }, locale:'fr' },
249
+
],
250
+
fallback:true,
251
+
}
252
+
}
253
+
```
254
+
255
+
For [Automatically Statically Optimized](/docs/advanced-features/automatic-static-optimization.md) and non-dynamic `getStaticProps` pages, **a version of the page will be generated for each locale**. This is important to consider because it can increase build times depending on how many locales are configured inside `getStaticProps`.
256
+
257
+
For example, if you have 50 locales configured with 10 non-dynamic pages using `getStaticProps`, this means `getStaticProps` will be called 500 times. 50 versions of the 10 pages will be generated during each build.
258
+
259
+
To decrease the build time of dynamic pages with `getStaticProps`, use a [`fallback` mode](https://nextjs.org/docs/basic-features/data-fetching#fallback-true). This allows you to return only the most popular paths and locales from `getStaticPaths` for prerendering during the build. Then, Next.js will build the remaining pages at runtime as they are requested.
260
+
237
261
### Automatically Statically Optimized Pages
238
262
239
263
For pages that are [automatically statically optimized](/docs/advanced-features/automatic-static-optimization.md), a version of the page will be generated for each locale.
For dynamic `getStaticProps` pages, any locale variants of the page that is desired to be prerendered needs to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching.md#getstaticpaths-static-generation). Along with the `params` object that can be returned for the `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
271
-
272
-
```js
273
-
// pages/blog/[slug].js
274
-
exportconstgetStaticPaths= ({ locales }) => {
275
-
return {
276
-
paths: [
277
-
{ params: { slug:'post-1' }, locale:'en-US' },
278
-
{ params: { slug:'post-1' }, locale:'fr' },
279
-
],
280
-
fallback:true,
281
-
}
282
-
}
283
-
```
284
-
285
292
## Limits for the i18n config
286
293
287
294
-`locales`: 100 total locales
288
295
-`domains`: 100 total locale domain items
296
+
297
+
> **Note:** These limits have been added initially to prevent potential [performance issues at build time](#dynamic-routes-and-getStaticProps-pages). We are continuing to evaluate if these limits are sufficient.
Copy file name to clipboardExpand all lines: docs/api-reference/next/image.md
+15-18Lines changed: 15 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,29 +90,26 @@ The `<Image />` component optionally accepts the following properties.
90
90
91
91
### layout
92
92
93
-
The layout behavior of the image as the viewport changes size. Defaults to
94
-
`intrinsic`.
93
+
The layout behavior of the image as the viewport changes size.
95
94
96
-
When `fixed`, the image dimensions will not change as the viewport changes (no
97
-
responsiveness) similar to the native `img` element.
98
-
99
-
When `intrinsic`, the image will scale the dimensions down for smaller viewports
100
-
but maintain the original dimensions for larger viewports.
101
-
102
-
When `responsive`, the image will scale the dimensions down for smaller
103
-
viewports and scale up for larger viewports.
104
-
Note: the responsive layout may not work correctly if the parent element uses a display value other than `block` such as `display: flex` or `display: grid`.
105
-
106
-
When `fill`, the image will stretch both width and height to the dimensions of
107
-
the parent element, provided the parent element is relative. This is usually paired with the [`objectFit`](#objectFit) property.
108
-
Ensure the parent element has `position: relative` in their stylesheet.
|`intrinsic` (default) | Scale *down* to fit width of container, up to image size |`1x`, `2x` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes)) | N/A |
98
+
|`fixed`| Sized to `width` and `height` exactly |`1x`, `2x` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes)) | N/A |
99
+
|`responsive`| Scale to fit width of container |`640w`, `750w`, ... `2048w`, `3840w` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes) and [deviceSizes](/docs/basic-features/image-optimization.md#device-sizes)) |`100vw`|
100
+
|`fill`| Grow in X and Y axes to fill container |`640w`, `750w`, ... `2048w`, `3840w` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes) and [deviceSizes](/docs/basic-features/image-optimization.md#device-sizes)) |`100vw`|
111
101
102
+
-[Demo the `intrinsic` layout (default)](https://image-component.nextjs.gallery/layout-intrinsic)
103
+
- When `intrinsic`, the image will scale the dimensions down for smaller viewports, but maintain the original dimensions for larger viewports.
112
104
-[Demo the `fixed` layout](https://image-component.nextjs.gallery/layout-fixed)
113
-
-[Demo the `intrinsic` layout](https://image-component.nextjs.gallery/layout-intrinsic)
105
+
- When `fixed`, the image dimensions will not change as the viewport changes (no responsiveness) similar to the native `img` element.
114
106
-[Demo the `responsive` layout](https://image-component.nextjs.gallery/layout-responsive)
107
+
- When `responsive`, the image will scale the dimensions down for smaller viewports and scale up for larger viewports.
108
+
- Ensure the parent element uses `display: block` in their stylesheet.
115
109
-[Demo the `fill` layout](https://image-component.nextjs.gallery/layout-fill)
110
+
- When `fill`, the image will stretch both width and height to the dimensions of the parent element, provided the parent element is relative.
111
+
- This is usually paired with the [`objectFit`](#objectFit) property.
112
+
- Ensure the parent element has `position: relative` in their stylesheet.
Copy file name to clipboardExpand all lines: docs/api-routes/introduction.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
@@ -55,7 +55,7 @@ For new projects, you can build your entire API with API Routes. If you have an
55
55
56
56
## Caveats
57
57
58
-
- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [cors middleware](/docs/api-routes/api-middlewares.md#connectexpress-middleware-support).
58
+
- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [CORS middleware](/docs/api-routes/api-middlewares.md#connectexpress-middleware-support).
59
59
- API Routes can't be used with [`next export`](/docs/advanced-features/static-html-export.md)
| ✔️ |[next/no-title-in-document-head](https://nextjs.org/docs/messages/no-title-in-document-head)| Disallow using <title> with Head from next/document |
96
96
| ✔️ |[next/no-unwanted-polyfillio](https://nextjs.org/docs/messages/no-unwanted-polyfillio)| Prevent duplicate polyfills from Polyfill.io |
97
+
| ✔️ |[next/inline-script-id](https://nextjs.org/docs/messages/inline-script-id)| Enforce id attribute on next/script components with inline content |
97
98
| ✔️ | next/no-typos | Ensure no typos were made declaring [Next.js's data fetching function](https://nextjs.org/docs/basic-features/data-fetching)|
98
99
| ✔️ |[next/next-script-for-ga](https://nextjs.org/docs/messages/next-script-for-ga)| Use the Script component to defer loading of the script until necessary. |
99
100
@@ -138,6 +139,14 @@ Similarly, the `--dir` flag can be used for `next lint`:
138
139
next lint --dir pages --dir utils
139
140
```
140
141
142
+
## Caching
143
+
144
+
To improve performance, information of files processed by ESLint are cached by default. This is stored in `.next/cache` or in your defined [build directory](/docs/api-reference/next.config.js/setting-a-custom-build-directory). If you include any ESLint rules that depend on more than the contents of a single source file and need to disable the cache, use the `--no-cache` flag with `next lint`.
145
+
146
+
```bash
147
+
next lint --no-cache
148
+
```
149
+
141
150
## Disabling Rules
142
151
143
152
If you would like to modify or disable any rules provided by the supported plugins (`react`, `react-hooks`, `next`), you can directly change them using the `rules` property in your `.eslintrc`:
Automatic Webfont Optimization currently supports Google Fonts and Typekit with support for other font providers coming soon. We're also planning to add control over [loading strategies](https://github.com/vercel/next.js/issues/21555) and `font-display` values.
78
78
79
+
See [Google Font Display](https://nextjs.org/docs/messages/google-font-display) for more information.
80
+
79
81
## Disabling Optimization
80
82
81
83
If you do not want Next.js to optimize your fonts, you can opt-out.
Copy file name to clipboardExpand all lines: docs/basic-features/image-optimization.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
@@ -128,7 +128,7 @@ If you need a different provider, you can use the [`loader`](/docs/api-reference
128
128
129
129
> The `next/image` component's default loader is not supported when using [`next export`](/docs/advanced-features/static-html-export.md). However, other loader options will work.
130
130
131
-
> The `next/image` component's default loader uses the ['squoosh'](https://www.npmjs.com/package/@squoosh/lib)library for image resizing and optimization. This library is quick to install and suitable for a dev server environment. For a production environment, it is strongly recommended that you install the optional [`sharp`](https://www.npmjs.com/package/sharp)library by running `yarn add sharp` in your project directory. If sharp is already installed but can't be resolved you can manually pass the path to it via the `NEXT_SHARP_PATH` environment variable e.g. `NEXT_SHARP_PATH=/tmp/node_modules/sharp`
131
+
> The `next/image` component's default loader uses [`squoosh`](https://www.npmjs.com/package/@squoosh/lib)because it is quick to install and suitable for a development environment. When using `next start` in your production environment, it is strongly recommended that you install [`sharp`](https://www.npmjs.com/package/sharp) by running `yarn add sharp` in your project directory. This is not necessary for Vercel deployments, as `sharp` is installed automatically.
0 commit comments