--- url: /reference/items/Prefetch.md --- # Prefetch The family of prefetch components can be used to improve performance when navigating in a page by prefetching content for the target links. ## Usage Import one of the available prefetch component in you app and use them in your HTML to enable a performance boost while navigating between pages. ::: code-group ```js twoslash [app.js] import { registerComponent } from '@studiometa/js-toolkit'; import { PrefetchWhenOver, PrefetchWhenVisible } from '@studiometa/ui'; registerComponent(PrefetchWhenOver); registerComponent(PrefetchWhenVisible); ``` ```html [index.html] ... ... ``` ::: ### Create your own prefetch strategy If you need a custom strategy to prefetch a given link, you can extend the `AbstractPrefetch` class exported by the package and call its [`prefetch()` method](./js-api.md#prefetch) when needed. ```js twoslash import { AbstractPrefetch } from '@studiometa/ui'; export default class PrefetchOnPointerdown extends AbstractPrefetch { static config = { name: 'AbstractPrefetch', }; onPointerdown() { this.prefetch(); } } ```