Skip to content

Commit 712d98d

Browse files
authored
Update docs for remotePatterns image config (#40350)
This updates the docs to favor `remotePatterns` image config (instead of `domains`)
1 parent 66834d5 commit 712d98d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

docs/api-reference/next/future/image.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Must be one of the following:
151151
2. A path string. This can be either an absolute external URL,
152152
or an internal path depending on the [loader](#loader) prop.
153153

154-
When using an external URL, you must add it to [domains](#domains) in `next.config.js`.
154+
When using an external URL, you must add it to [remotePatterns](#remote-patterns) in `next.config.js`.
155155

156156
### width
157157

@@ -430,6 +430,8 @@ The `**` syntax does not work in the middle of the pattern.
430430

431431
### Domains
432432

433+
> Note: We recommend using [`remotePatterns`](#remote-patterns) instead so you can restrict protocol and pathname.
434+
433435
Similar to [`remotePatterns`](#remote-patterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images.
434436

435437
However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname.

docs/api-reference/next/image.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Must be one of the following:
4545
or an internal path depending on the [loader](#loader) prop or [loader configuration](#loader-configuration).
4646

4747
When using an external URL, you must add it to
48-
[domains](#domains) in
48+
[remotePatterns](#remote-patterns) in
4949
`next.config.js`.
5050

5151
### width
@@ -393,6 +393,8 @@ The `**` syntax does not work in the middle of the pattern.
393393

394394
### Domains
395395

396+
> Note: We recommend using [`remotePatterns`](#remote-patterns) instead so you can restrict protocol and pathname.
397+
396398
Similar to [`remotePatterns`](#remote-patterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images.
397399

398400
However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname.

docs/basic-features/image-optimization.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Home() {
7272

7373
### Remote Images
7474

75-
To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](/docs/api-reference/next/image.md#domains). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually:
75+
To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](/docs/api-reference/next/image.md#remote-patterns). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually:
7676

7777
```jsx
7878
import Image from 'next/image'
@@ -97,17 +97,17 @@ export default function Home() {
9797
9898
### Domains
9999

100-
Sometimes you may want to access a remote image, but still use the built-in Next.js Image Optimization API. To do this, leave the `loader` at its default setting and enter an absolute URL for the Image `src`.
100+
Sometimes you may want to optimize a remote image, but still use the built-in Next.js Image Optimization API. To do this, leave the `loader` at its default setting and enter an absolute URL for the Image `src` prop.
101101

102-
To protect your application from malicious users, you must define a list of remote hostnames you intend to allow remote access.
102+
To protect your application from malicious users, you must define a list of remote hostnames you intend to use with the `next/image` component.
103103

104-
> Learn more about [`domains`](/docs/api-reference/next/image.md#domains) configuration.
104+
> Learn more about [`remotePatterns`](/docs/api-reference/next/image.md#remote-patterns) configuration.
105105
106106
### Loaders
107107

108108
Note that in the [example earlier](#remote-images), a partial URL (`"/me.png"`) is provided for a remote image. This is possible because of the `next/image` [loader](/docs/api-reference/next/image.md#loader) architecture.
109109

110-
A loader is a function that generates the URLs for your image. It appends a root domain to your provided `src`, and generates multiple URLs to request the image at different sizes. These multiple URLs are used in the automatic [srcset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) generation, so that visitors to your site will be served an image that is the right size for their viewport.
110+
A loader is a function that generates the URLs for your image. It modifies the provided `src`, and generates multiple URLs to request the image at different sizes. These multiple URLs are used in the automatic [srcset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) generation, so that visitors to your site will be served an image that is the right size for their viewport.
111111

112112
The default loader for Next.js applications uses the built-in Image Optimization API, which optimizes images from anywhere on the web, and then serves them directly from the Next.js web server. If you would like to serve your images directly from a CDN or image server, you can use one of the [built-in loaders](/docs/api-reference/next/image.md#built-in-loaders) or write your own with a few lines of JavaScript.
113113

@@ -209,7 +209,7 @@ For examples of the Image component used with the various fill modes, see the [I
209209

210210
## Configuration
211211

212-
The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote images](/docs/api-reference/next/image.md#domains), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more.
212+
The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote images](/docs/api-reference/next/image.md#remote-patterns), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more.
213213

214214
[**Read the full image configuration documentation for more information.**](/docs/api-reference/next/image.md#configuration-options)
215215

0 commit comments

Comments
 (0)