I’m a big fan of Vue JS. So, when heading into mobile app development, Native script was the one thing which made me excited to work on. For those who are new to this, Nativescript is an open source framework which is used to create true native mobile apps for both Android and IOS. Nativescript supports Angular, Vue, Vanilla JS and Typescript. It is known for its performance, compared to other mobile app development frameworks like react native and ionic.
Here in this blog, we are going to focus on nativescript-vue routing…
Nativescript-vue is basically, Nativescript core combined with Vue JS.
Let’s go ahead with manual routing…
To implement manual routing, you just need to know the following three methods:

How do we implement routing in nativescript-vue?
The shocking news here is, Vue routing is not supported in nativescript-vue. The Nativescript community is currently working on it. But for now, we have to go with manual routing methods.
- $navigateTo
- $navigateBack
- $showModal
-
$navigateTo:
goToHomePage() { this.$navigateTo(HomePage); }There might be a scenario where we need to pass data from one component to another component. In that case, the data can be passed as props using the $navigateTo method by.
this.$navigateTo(ComponentName, { props: { // pass the data as an object here } });
What else we can do with “$navigateTo”?
This method also gives us properties to apply transitions while navigating to the next page. There are three ways to set the transition:- transition: Applies on all platforms.
- transitioniOS: Applies only to IOS.
- transitionAndroid: Applies only to Android.
this.$navigateTo(NextComponent, { transition: { name: 'flip', duration: 2000, } });The below listed are the available transitions:
- curl (same as curlUp) (iOS only)
- curlUp (iOS only)
- curlDown (iOS only)
- explode (Android Lollipop(21) and up only)
- fade
- flip (same as flipRight)
- flipRight
- flipLeft
- slide (same as slideLeft)
- slideLeft
- slideRight
- slideTop
- slideBottom
- $navigateBack:
- $showModal:
this.$showModal(Component, { props: { message: “Props is passed here” }});That’s it…. We have now mastered manual routing in nativescript-vue by learning simple three methods. Hope this blog was helpful and let me know your thoughts on this in the comments! Thanks for reading!
Reference:
https://nativescript-vue.org/en/docs/routing/manual-routing
Tagged JavascriptNativescriptvue