Skip to content

Navigating ​

ts
router.push('/messages/42?from=push')
router.push({ name: 'message', params: { id: 42 }, query: { from: 'push' } })
router.replace('/login')
router.back()
router.go(-2)
router.backTo({ name: 'inbox' }) // closest page below that matches
router.backToRoot() // first page of the stack

Everything returns a promise that settles once the page is on screen, with a NavigationFailure when a guard stopped it, like Vue Router.

Options ​

A second argument takes what only makes sense on a device:

ts
router.push('/messages/42', {
  transition: 'slideLeft', // or a full NativeScript transition object
  animated: false,
  clearHistory: true, // nothing left to go back to
  props: { preview }, // any value, unlike params
  frame: 'profile', // a named <RouterView>
  modal: true, // present modally, whatever the route says
  withParents: true, // push the route's parents first
})

back() takes animated, frame and result (see Modals and results).

Double taps ​

Navigations queue behind native transitions, so a double tap on a button opens the page once: the second push finds the page already on top and resolves with a duplicated failure.

RouterLink makes its only child navigate on tap, without adding a view:

vue
<RouterLink to="/settings">
  <Button text="Settings" />
</RouterLink>

It takes to, replace, clearHistory, withParents, transition and frame.

Released under the MIT License.