Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 31d6f05

Browse files
authored
site: adds example to goto documentation (#1055)
1 parent d062e75 commit 31d6f05

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

site/content/docs/03-client-api.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,20 @@ sapper.start({
3131

3232
Programmatically navigates to the given `href`. If the destination is a Sapper route, Sapper will handle the navigation, otherwise the page will be reloaded with the new `href`. In other words, the behaviour is as though the user clicked on a link with this `href`.
3333

34-
Returns a `Promise` that resolves when the navigation is complete.
34+
Returns a `Promise` that resolves when the navigation is complete. This can be used to perform actions once the navigation has completed, such as updating a database, store, etc.
35+
36+
```js
37+
import { goto } from '@sapper/app';
38+
39+
const navigateAndSave = async () => {
40+
await goto('/');
41+
saveItem();
42+
}
43+
44+
const saveItem = () => {
45+
// do something with the database
46+
}
47+
```
3548

3649

3750
### prefetch(href)

0 commit comments

Comments
 (0)