> For the complete documentation index, see [llms.txt](https://jho406.gitbook.io/breezy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jho406.gitbook.io/breezy/docs/reference/types.requests.md).

# Interfaces

## Visit()

> **Visit**(`input`: `string`, `options`: [`VisitProps`](#visitprops)): `Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

Use visit to make single page transitions from one page. The function is a wrapper around fetch and made to mimic a link click or a form submision. When used, a `json` request will be made for the next page, then Superglue saves the response, swap the page component, and change the browser history.

!!! note There can be only one `visit` at a time. If another `visit` is called from elsewhere, the previous visit would be aborted.

You must provide the implentation and pass it back to Superglue in `application.js`. Superglue will then pass it to your page components and use it for UJS navigation. This is usually generated for you in `application_visit.js` where you can customize its behavior globally.

### Parameters

| Parameter | Type                        | Description                 |
| --------- | --------------------------- | --------------------------- |
| `input`   | `string`                    | The first argument to Fetch |
| `options` | [`VisitProps`](#visitprops) |                             |

### Returns

`Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

### Defined in

[lib/types/requests.ts:22](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L22)

***

## VisitProps

Options for Visit

### Extends

* `Omit`<`BaseProps`, `"signal"`>

### Properties

| Property          | Type                          | Description                                                                                                                                                                                                                               | Inherited from    | Defined in                                                                                                                                            |
| ----------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `placeholderKey?` | `string`                      | Defaults to the currentPageKey. When present, Superglue will use the page state located at that pageKey and optimistally navigates to it as the next page's state while the requests resolves.                                            | -                 | [lib/types/requests.ts:36](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L36) |
| `revisit?`        | `boolean`                     | When `true` and the request method is a GET, changes the `suggestionAction` of the Meta object to `none` so that Superglue does nothing to window\.history. When the GET response was redirected, changes `navigationAction` to `replace` | -                 | [lib/types/requests.ts:43](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L43) |
| `method?`         | `string`                      | The HTTP method                                                                                                                                                                                                                           | `Omit.method`     | [lib/types/requests.ts:68](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L68) |
| `body?`           | `BodyInit`                    | The HTTP body                                                                                                                                                                                                                             | `Omit.body`       | [lib/types/requests.ts:70](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L70) |
| `headers?`        | {}                            | The HTTP headers                                                                                                                                                                                                                          | `Omit.headers`    | [lib/types/requests.ts:72](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L72) |
| `beforeSave?`     | [`BeforeSave`](#beforesave-2) | -                                                                                                                                                                                                                                         | `Omit.beforeSave` | [lib/types/requests.ts:75](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L75) |

***

## Remote()

> **Remote**(`input`: `string`, `options`: [`RemoteProps`](#remoteprops)): `Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

Remote is is wrapper around fetch. Its used to make a request and mutate the store. Remote does not navigate, and it does not change the browser history. There can be multiple Remote requests running concurrently.

This function is to be wrapped by a deverloper as a [ApplicationRemote](#applicationremote) and returned to superglue. This is usually generated as `application_visit.js` where you can make minimum edits to affect its global usage.

### Parameters

| Parameter | Type                          | Description                                   |
| --------- | ----------------------------- | --------------------------------------------- |
| `input`   | `string`                      | The first argument to Fetch                   |
| `options` | [`RemoteProps`](#remoteprops) | The fetch RequestInit with additional options |

### Returns

`Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

### Defined in

[lib/types/requests.ts:60](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L60)

***

## RemoteProps

Options for Visit

### Extends

* `BaseProps`

### Properties

| Property      | Type                          | Description                                                                                                                                                                                                                                                                                                                                                                                                             | Inherited from         | Defined in                                                                                                                                            |
| ------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `method?`     | `string`                      | The HTTP method                                                                                                                                                                                                                                                                                                                                                                                                         | `BaseProps.method`     | [lib/types/requests.ts:68](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L68) |
| `body?`       | `BodyInit`                    | The HTTP body                                                                                                                                                                                                                                                                                                                                                                                                           | `BaseProps.body`       | [lib/types/requests.ts:70](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L70) |
| `headers?`    | {}                            | The HTTP headers                                                                                                                                                                                                                                                                                                                                                                                                        | `BaseProps.headers`    | [lib/types/requests.ts:72](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L72) |
| `beforeSave?` | [`BeforeSave`](#beforesave-2) | -                                                                                                                                                                                                                                                                                                                                                                                                                       | `BaseProps.beforeSave` | [lib/types/requests.ts:75](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L75) |
| `pageKey?`    | `string`                      | Specifies where to store the remote payload, if not provided [Remote](#remote) will derive a key from the response's url.                                                                                                                                                                                                                                                                                               | -                      | [lib/types/requests.ts:86](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L86) |
| `force?`      | `boolean`                     | By default, remote [Remote](#remote) disallows grafting a page response using props\_at if the target pageKey provided has a different componentIdentifier. Setting `force: true` will ignore this limitation. This can be useful if you are absolutely sure that the page your grafting onto has a compatible shape with the response received with using props\_at. A good example of this is a shared global header. | -                      | [lib/types/requests.ts:96](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L96) |

***

## BeforeSave()

> **BeforeSave**(`prevPage`: [`VisitResponse`](/breezy/docs/reference/types.md#visitresponset), `receivedPage`: [`VisitResponse`](/breezy/docs/reference/types.md#visitresponset)): [`VisitResponse`](/breezy/docs/reference/types.md#visitresponset)

A callback that will be fire in between recieving a payload and saving a payload. Use this callback to modify the payload before it gets saved. Its useful for appending, prepending, shuffeling, etc. recieved data to existing data.

```
const beforeSave = (prevPage, nextPage) => {
  nextPage.data.messages = [
    prevPage.data.messages,
    ... nextPage.data.messages
  ]

  return nextPage
}

remote("/posts", {beforeSave})
```

### Parameters

| Parameter      | Type                                                              |
| -------------- | ----------------------------------------------------------------- |
| `prevPage`     | [`VisitResponse`](/breezy/docs/reference/types.md#visitresponset) |
| `receivedPage` | [`VisitResponse`](/breezy/docs/reference/types.md#visitresponset) |

### Returns

[`VisitResponse`](/breezy/docs/reference/types.md#visitresponset)

### Defined in

[lib/types/requests.ts:119](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L119)

***

## ApplicationRemote()

> **ApplicationRemote**(`input`: `string`, `options`: [`RemoteProps`](#remoteprops) & {`dataset`: {}; }): `Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

ApplicationRemote is the developer provided wrapper around [Remote](#remote).

It contains custom functionality, but is bound by the interface that Superglue uses to make a `remote` call. See [Remote](#remote) for more details.

The only difference between the two interfaces is ApplicationRemote will also be passed a dataset as an option. This is because Superglue UJS uses ApplicationRemote and will pass the dataset of the HTML element where UJS is enabled on.

### Parameters

| Parameter | Type                                              |
| --------- | ------------------------------------------------- |
| `input`   | `string`                                          |
| `options` | [`RemoteProps`](#remoteprops) & {`dataset`: {}; } |

### Returns

`Promise`<[`Meta`](/breezy/docs/reference/types.md#meta)>

### Defined in

[lib/types/requests.ts:134](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L134)

***

## ApplicationVisit()

> **ApplicationVisit**(`input`: `string`, `options`: [`VisitProps`](#visitprops) & {`dataset`: {}; }): `Promise`<`undefined` | `void` | [`VisitMeta`](/breezy/docs/reference/types.md#visitmeta)>

ApplicationVisit is the developer provided wrapper around [Remote](#remote).

It contains custom functionality, but is bound by the interface that Superglue uses to make a `visit` call. See [Remote](#remote) for more details.

The only difference between the two interfaces is ApplicationVisit will also be passed a dataset as an option. This is because Superglue UJS uses ApplicationVisit and will pass the dataset of the HTML element where UJS is enabled on.

### Parameters

| Parameter | Type                                            |
| --------- | ----------------------------------------------- |
| `input`   | `string`                                        |
| `options` | [`VisitProps`](#visitprops) & {`dataset`: {}; } |

### Returns

`Promise`<`undefined` | `void` | [`VisitMeta`](/breezy/docs/reference/types.md#visitmeta)>

### Defined in

[lib/types/requests.ts:156](https://github.com/thoughtbot/superglue/blob/082475a624bd2c23522d97710a5b2ed335eb293c/superglue/lib/types/requests.ts#L156)
