---
name: "up.visit"
area: "API"
kind: "JavaScript function"
parent: "up.fragment module"
url: "https://unpoly.com/api/up.visit"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.fragment module](https://unpoly.com/api/up.fragment.md)</nav>

# up.visit(url, [options])

Fetches the given URL with JavaScript and [replaces](https://unpoly.com/api/up.render.md) the [current layer](https://unpoly.com/api/up.layer.current.md)'s [main fragment](https://unpoly.com/api/up.fragment.config.md#config.mainTargets) with a matching fragment from the server response.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

This would replace the current page with the response for `/users`:

```js
up.visit('/users')
```

---

## Parameters {#parameters}

### Destination {#parameters-destination}

#### url {#url}

(required)

The URL to visit.

Type: string

### Render options {#parameters-render-options}

#### [options] {#options}

(optional)

Additional [render options](https://unpoly.com/api/up.render.md#parameters) to use for rendering the destination URL.

Most [options for `up.render()`](https://unpoly.com/api/up.render.md#parameters) may be used.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

---

## Return value {#return-value}

A promise that fulfills with an [`up.RenderResult`](https://unpoly.com/api/up.RenderResult.md) once the page has been updated.

The promise rejects when one of the following conditions occur:

- the render pass was [aborted](https://unpoly.com/learn/aborting-requests.md)
- the server sends an [error status](https://unpoly.com/learn/error-responses.md)
- there is a [network issue](https://unpoly.com/learn/network-issues.md)
- [targets](https://unpoly.com/learn/targeting-fragments.md) could not be matched

See [Render lifecycle hooks](https://unpoly.com/learn/render-lifecycle.md) for more information about handling errors, or running code after rendering.

Type: [up.RenderJob](https://unpoly.com/api/up.RenderJob.md)

