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
Update to stable: next/future/image, remotePatterns, unoptimized (vercel#40142)
This PR updates a few features from experimental to stable status:
- `next/future/image` component
- `remotePatterns` configuration
- `unoptimized` configuration
The `next/future/image` component is an experiment to improve both the performance and developer experience of `next/image` by using the native `<img>` element with better default behavior.
18
+
The `next/future/image` component improves both the performance and developer experience of `next/image` by using the native `<img>` element with better default behavior.
19
19
20
-
This new component is considered experimental and therefore not covered by semver, and may cause unexpected or broken application behavior. This component uses browser native [lazy loading](https://caniuse.com/loading-lazy-attr), which may fallback to eager loading for older browsers before Safari 15.4. When using the blur-up placeholder, older browsers before Safari 12 will fallback to empty placeholder. When using styles with `width`/`height` of `auto`, it is possible to cause [Layout Shift](https://web.dev/cls/) on older browsers before Safari 15 that don't [preserve the aspect ratio](https://caniuse.com/mdn-html_elements_img_aspect_ratio_computed_from_attributes). For more details, see [this MDN video](https://www.youtube.com/watch?v=4-d_SoCHeWE).
21
-
22
-
To use `next/future/image`, add the following to your `next.config.js` file:
23
-
24
-
```js
25
-
module.exports= {
26
-
experimental: {
27
-
images: {
28
-
allowFutureImage:true,
29
-
},
30
-
},
31
-
}
32
-
```
20
+
This component uses browser native [lazy loading](https://caniuse.com/loading-lazy-attr), which may fallback to eager loading for older browsers before Safari 15.4. When using the blur-up placeholder, older browsers before Safari 12 will fallback to empty placeholder. When using styles with `width`/`height` of `auto`, it is possible to cause [Layout Shift](https://web.dev/cls/) on older browsers before Safari 15 that don't [preserve the aspect ratio](https://caniuse.com/mdn-html_elements_img_aspect_ratio_computed_from_attributes). For more details, see [this MDN video](https://www.youtube.com/watch?v=4-d_SoCHeWE).
33
21
34
22
## Comparison
35
23
@@ -374,14 +362,12 @@ You can also [generate a solid color Data URL](https://png-pixel.com) to match t
374
362
When true, the source image will be served as-is instead of changing quality,
375
363
size, or format. Defaults to `false`.
376
364
377
-
This prop can be assigned to all images by updating `next.config.js` with the following experimental configuration:
365
+
This prop can be assigned to all images by updating `next.config.js` with the following configuration:
378
366
379
367
```js
380
368
module.exports= {
381
-
experimental: {
382
-
images: {
383
-
unoptimized:true,
384
-
},
369
+
images: {
370
+
unoptimized:true,
385
371
},
386
372
}
387
373
```
@@ -399,23 +385,19 @@ Other properties on the `<Image />` component will be passed to the underlying
399
385
400
386
### Remote Patterns
401
387
402
-
> Note: The `remotePatterns` configuration is currently **experimental** and subject to change. Please use [`domains`](#domains) for production use cases.
403
-
404
388
To protect your application from malicious users, configuration is required in order to use external images. This ensures that only external images from your account can be served from the Next.js Image Optimization API. These external images can be configured with the `remotePatterns` property in your `next.config.js` file, as shown below:
405
389
406
390
```js
407
391
module.exports= {
408
-
experimental: {
409
-
images: {
410
-
remotePatterns: [
411
-
{
412
-
protocol:'https',
413
-
hostname:'example.com',
414
-
port:'',
415
-
pathname:'/account123/**',
416
-
},
417
-
],
418
-
},
392
+
images: {
393
+
remotePatterns: [
394
+
{
395
+
protocol:'https',
396
+
hostname:'example.com',
397
+
port:'',
398
+
pathname:'/account123/**',
399
+
},
400
+
],
419
401
},
420
402
}
421
403
```
@@ -426,15 +408,13 @@ Below is another example of the `remotePatterns` property in the `next.config.js
|`v12.1.1`|`style` prop added. Experimental[\*](#experimental-raw-layout-mode) support for `layout="raw"` added. |
21
22
|`v12.1.0`|`dangerouslyAllowSVG` and `contentSecurityPolicy` configuration added. |
@@ -93,8 +94,6 @@ The layout behavior of the image as the viewport changes size.
93
94
- When `fill`, the image will stretch both width and height to the dimensions of the parent element, provided the parent element is relative.
94
95
- This is usually paired with the [`objectFit`](#objectFit) property.
95
96
- Ensure the parent element has `position: relative` in their stylesheet.
96
-
- When `raw`[\*](#experimental-raw-layout-mode), the image will be rendered as a single image element with no wrappers, sizers or other responsive behavior.
97
-
- If your image styling will change the size of a `raw` image, you should include the `sizes` property for proper image serving. Otherwise your image will be requested as though it has fixed width and height.
When true, the source image will be served as-is instead of changing quality,
325
324
size, or format. Defaults to `false`.
326
325
327
-
This prop can be assigned to all images by updating `next.config.js` with the following experimental configuration:
326
+
This prop can be assigned to all images by updating `next.config.js` with the following configuration:
328
327
329
328
```js
330
329
module.exports= {
331
-
experimental: {
332
-
images: {
333
-
unoptimized:true,
334
-
},
330
+
images: {
331
+
unoptimized:true,
335
332
},
336
333
}
337
334
```
@@ -351,23 +348,19 @@ Other properties on the `<Image />` component will be passed to the underlying
351
348
352
349
### Remote Patterns
353
350
354
-
> Note: The `remotePatterns` configuration is currently **experimental** and subject to change. Please use [`domains`](#domains) for production use cases.
355
-
356
351
To protect your application from malicious users, configuration is required in order to use external images. This ensures that only external images from your account can be served from the Next.js Image Optimization API. These external images can be configured with the `remotePatterns` property in your `next.config.js` file, as shown below:
357
352
358
353
```js
359
354
module.exports= {
360
-
experimental: {
361
-
images: {
362
-
remotePatterns: [
363
-
{
364
-
protocol:'https',
365
-
hostname:'example.com',
366
-
port:'',
367
-
pathname:'/account123/**',
368
-
},
369
-
],
370
-
},
355
+
images: {
356
+
remotePatterns: [
357
+
{
358
+
protocol:'https',
359
+
hostname:'example.com',
360
+
port:'',
361
+
pathname:'/account123/**',
362
+
},
363
+
],
371
364
},
372
365
}
373
366
```
@@ -378,15 +371,13 @@ Below is another example of the `remotePatterns` property in the `next.config.js
`The "next/future/image" component is experimental and may be subject to breaking changes. To enable this experiment, please include \`experimental: { images: { allowFutureImage: true } }\` in your next.config.js file.`
0 commit comments