mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
a5f1682347
* feat: add experimental client prerender * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * docs: add more details about effects of the feature * add changeset * add tests * edit jsdoc and changeset with suggestions * Update packages/astro/src/@types/astro.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update packages/astro/src/prefetch/index.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update .changeset/sixty-dogs-sneeze.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/sixty-dogs-sneeze.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/sixty-dogs-sneeze.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
24 lines
No EOL
973 B
Markdown
24 lines
No EOL
973 B
Markdown
---
|
|
"astro": minor
|
|
---
|
|
|
|
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).
|
|
|
|
```js
|
|
// astro.config.mjs
|
|
{
|
|
prefetch: {
|
|
prefetchAll: true,
|
|
defaultStrategy: 'viewport',
|
|
},
|
|
experimental: {
|
|
clientPrerender: true,
|
|
},
|
|
}
|
|
```
|
|
|
|
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.
|
|
|
|
Client side prerendering requires browser support. If the Speculation Rules API is not supported, `prefetch` will fallback to the supported strategy.
|
|
|
|
See the [Prefetch Guide](https://docs.astro.build/en/guides/prefetch/) for more `prefetch` options and usage. |