Skip to content

Commit 6778d2b

Browse files
committed
Add docs for replace utility
1 parent 8334033 commit 6778d2b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/fetch/replace.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: replace
3+
new: true
4+
---
5+
6+
# `replace`
7+
8+
This is a small wrapper around [`redirect`][redirect] that will trigger a client-side redirect to the new location using `history.replaceState` instead of `history.pushState`.
9+
10+
## Type Declaration
11+
12+
```ts
13+
type RedirectFunction = (
14+
url: string,
15+
init?: number | ResponseInit
16+
) => Response;
17+
```
18+
19+
## `url`
20+
21+
The URL to redirect to.
22+
23+
```js
24+
replace("/otherapp/login");
25+
```
26+
27+
## `init`
28+
29+
The `status` or the [Response][response] options to be used in the response.
30+
31+
[response]: https://developer.mozilla.org/en-US/docs/Web/API/Response/Response
32+
[redirect]: ./redirect

0 commit comments

Comments
 (0)