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

Commit

Permalink
site: adds example to goto documentation (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmodrome committed Feb 26, 2020
1 parent d062e75 commit 31d6f05
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion site/content/docs/03-client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@ sapper.start({

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`.

Returns a `Promise` that resolves when the navigation is complete.
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.

```js
import { goto } from '@sapper/app';

const navigateAndSave = async () => {
await goto('/');
saveItem();
}

const saveItem = () => {
// do something with the database
}
```


### prefetch(href)
Expand Down

0 comments on commit 31d6f05

Please sign in to comment.