---
tags: brew-js
---
# Router methods
### `app.navigate`
```typescript
navigate(path, replace?): Promise<NavigateResult>
navigate(path, replace, data): Promise<NavigateResult> // since 0.4.10
```
### `app.back`
```typescript
back(): Promise<NavigateResult> | false
back(defaultPath): Promise<NavigateResult>
```
### `app.snapshot`
==Since `0.4.9`==
Push a new state to history stack without navigation.
```typescript!
snapshot(): boolean
```
### `app.resolvePath`
Resolves given path by substituting current route parameters.
```typescript
resolvePath(path: string, refPath?: string): string
```
###### Parameters
`path` --- A relative or absolute path that may contains route parameters.
Path starting with `~/` is resolved against the current route, without the trailing part matched by wildcard.
Path containing any relative path segment (`.` or `..`) will also be correctly resolved.
However, it will never resolve to path that is parent to the app's base path.
### `app.parseRoute`
```typescript!
parseRoute(pattern: string): RoutePattern
```
See [`RoutePattern` object](/Lbbh2zA2RKuiofKDOxsyXw).
### `app.matchRoute`
```typescript!
matchRoute(route: string, path: string, ignoreExact?: boolean): boolean
```
### `app.isAppPath`
==Since `0.4.8`==
Check whether a href corresponds to a valid app path.
```typescript
isAppPath(path: string): boolean
```
It expects the path to be absolute path. Giving a full URL will always return `false`.
Behavior on different router mode:
| `urlMode` | Page URL | Is app path | Not app path |
| ------------------------------ | ------------- | -------------------------- | -------------------------- |
| `pathname` | `/` | `/home` | - |
| `pathname` (`baseUrl=/base`) | `/base` | `/base/home` | `/home` |
| `query` (`queryParam=path`) | `/index.html` | `/index.html?path=%2Fhome` | `/other.html?path=%2Fhome` |
| `none` | `/index.html` | (none) | (all) |
:::info
It is internally used to check whether the action of clicking a link should be intercepted.
:::
### `app.toHref`
==Since `0.4.10`==
Converts an app path to a href.
```typescript
toHref(path: string): string;
```
Behavior on different router mode:
| `urlMode` | Page URL | Input | Output |
| -------------------------------------- | ------------- | ------------ | -------------------------- |
| `pathname` | `/` | `/home` | `/home` |
| `pathname` (`baseUrl=/base`, implicit) | `/base` | `/home` | `/base/home` |
| `pathname` (`baseUrl=/base`, explicit) | `/base` | `/base/home` | `/base/home` |
| `query` (`queryParam=path`) | `/index.html` | `/home` | `/index.html?path=%2Fhome` |
| `none` | `/index.html` | - | - |
:::info
It is internally used to update browser's current address when navigating.
:::
### `app.fromHref`
==Since `0.4.10`==
Converts a href to an app path.
```typescript
fromHref(path: string): string;
```
Behavior on different router mode:
| `urlMode` | Page URL | Input | Output |
| -------------------------------------- | ------------- | -------------------------- | ------------ |
| `pathname` | `/` | `/home` | `/home` |
| `pathname` (`baseUrl=/base`, implicit) | `/base` | `/base/home` | `/home` |
| `pathname` (`baseUrl=/base`, explicit) | `/base` | `/base/home` | `/base/home` |
| `query` (`queryParam=path`) | `/index.html` | `/index.html?path=%2Fhome` | `/home` |
| `none` | `/index.html` | - | - |
:::info
It is internally used to navigate the app when clicking a link that corresponds to a valid app path.
:::