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
Adds an experimental flag `clientPrerender` to prerender your prefetched pages on the client with the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API).
6
+
7
+
```js
8
+
// astro.config.mjs
9
+
{
10
+
prefetch: {
11
+
prefetchAll:true,
12
+
defaultStrategy:'viewport',
13
+
},
14
+
experimental: {
15
+
clientPrerender:true,
16
+
},
17
+
}
18
+
```
19
+
20
+
Enabling this feature overrides the default `prefetch` behavior globally to prerender links on the client according to your `prefetch` configuration. Instead of appending a `<link>` tag to the head of the document or fetching the page with JavaScript, a `<script>` tag will be appended with the corresponding speculation rules.
21
+
22
+
Client side prerendering requires browser support. If the Speculation Rules API is not supported, `prefetch` will fallback to the supported strategy.
23
+
24
+
See the [Prefetch Guide](https://docs.astro.build/en/guides/prefetch/) for more `prefetch` options and usage.
* Enables pre-rendering your prefetched pages on the client in supported browsers.
1578
+
*
1579
+
* This feature uses the experimental [Speculation Rules Web API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) and overrides the default `prefetch` behavior globally to prerender links on the client.
1580
+
* You may wish to review the [possible risks when prerendering on the client](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API#unsafe_prefetching) before enabling this feature.
1581
+
*
1582
+
* Enable client side prerendering in your `astro.config.mjs` along with any desired `prefetch` configuration options:
1583
+
*
1584
+
* ```js
1585
+
* // astro.config.mjs
1586
+
* {
1587
+
* prefetch: {
1588
+
* prefetchAll: true,
1589
+
* defaultStrategy: 'viewport',
1590
+
* },
1591
+
* experimental: {
1592
+
* clientPrerender: true,
1593
+
* },
1594
+
* }
1595
+
* ```
1596
+
*
1597
+
* Continue to use the `data-astro-prefetch` attribute on any `<a />` link on your site to opt in to prefetching.
1598
+
* Instead of appending a `<link>` tag to the head of the document or fetching the page with JavaScript, a `<script>` tag will be appended with the corresponding speculation rules.
1599
+
*
1600
+
* Client side prerendering requires browser support. If the Speculation Rules API is not supported, `prefetch` will fallback to the supported strategy.
1601
+
*
1602
+
* See the [Prefetch Guide](https://docs.astro.build/en/guides/prefetch/) for more `prefetch` options and usage.
`Invalid or outdated experimental feature.\nCheck for incorrect spelling or outdated Astro version.\nSee https://docs.astro.build/en/reference/configuration-reference/#experimental-flags for a list of all current experiments.`
0 commit comments