---
url: /reference/items/Fetch.md
---
# Fetch
The `Fetch` component adds AJAX capabilities to your existing HTML, with support for the [View Transition API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API) to transition between states.
## Usage
The `Fetch` component can be used to perform GET or POST requests without reloading the page.
```js twoslash
import { registerComponents } from '@studiometa/js-toolkit';
import { Fetch } from '@studiometa/ui';
registerComponents(Fetch);
```
### Basic
Given the following HTML:
```html
Click me
```
And the following response from the `/some-content` endpoint:
```html
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Some extra content.
```
Clicking on the link will dispatch a background fetch request and will replace the `` element with the new content from the fetch response. The page will have the following HTML after:
```html
Click me
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
```
::: warning 💡 Important
We use `id` attributes to detect which content from the response should be used and injected in the DOM. Any content from the response not nested in a parent with an `id` attribute will be discarded.
:::
A click with a modifier key, a middle click and a link with a `target` other than `_self` are left to the browser. A link without a `target` of its own takes the `target` of the `` element, as natively.
### From any element
The `Fetch` component is not limited to `` and `