{"id":15141913,"url":"https://github.com/nativescript-vue/nativescript-vue-navigator","last_synced_at":"2025-10-23T18:30:56.058Z","repository":{"id":34761920,"uuid":"157848445","full_name":"nativescript-vue/nativescript-vue-navigator","owner":"nativescript-vue","description":"A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components","archived":false,"fork":false,"pushed_at":"2022-10-14T21:01:28.000Z","size":151,"stargazers_count":98,"open_issues_count":31,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-30T20:29:57.300Z","etag":null,"topics":["nativescript","nativescript-plugin","nativescript-vue","navigation","router"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nativescript-vue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-16T10:00:36.000Z","updated_at":"2024-05-30T15:44:03.000Z","dependencies_parsed_at":"2022-08-08T02:00:31.681Z","dependency_job_id":null,"html_url":"https://github.com/nativescript-vue/nativescript-vue-navigator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-vue%2Fnativescript-vue-navigator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-vue%2Fnativescript-vue-navigator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-vue%2Fnativescript-vue-navigator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-vue%2Fnativescript-vue-navigator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nativescript-vue","download_url":"https://codeload.github.com/nativescript-vue/nativescript-vue-navigator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237869283,"owners_count":19379294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nativescript","nativescript-plugin","nativescript-vue","navigation","router"],"created_at":"2024-09-26T09:20:30.130Z","updated_at":"2025-10-23T18:30:50.699Z","avatar_url":"https://github.com/nativescript-vue.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeScript-Vue-Navigator\n\nNativeScript-Vue-Navigator is a simple router implementation that is suitable for NativeScript-Vue. \n\n## Quick Start\n\n```shell\n$ npm install --save nativescript-vue-navigator\n```\n\n```diff\n// main.js\nimport Vue from 'nativescript-vue'\n...\n+ import Navigator from 'nativescript-vue-navigator'\n+ import {routes} from './routes'\n+ Vue.use(Navigator, { routes })\n\nnew Vue({\n-   render: h =\u003e h('frame', App),\n+   render: h =\u003e h(App),\n}).$start()\n```\n\n```js\n// routes.js\nimport HomePage from './components/HomePage'\nimport LoginPage from './components/LoginPage'\n\nexport const routes = {\n  '/home': {\n    component: HomePage,\n  },\n  '/login': {\n    component: LoginPage,\n  },\n}\n```\n\n```diff\n// App.vue\n\u003ctemplate\u003e\n+  \u003cNavigator :defaultRoute=\"isLoggedIn ? '/home' : '/login'\"/\u003e\n\u003c/template\u003e\n```\n\n### Attaching extra data to a route\n\n```diff\n// routes.js\nimport HomePage from './components/HomePage'\nimport LoginPage from './components/LoginPage'\n\nexport const routes = {\n  '/home': {\n    component: HomePage,\n+   // we are using `meta` as a good practice, but you are free to use something else\n+   meta: { needsAuth: true }\n  },\n  '/login': {\n    component: LoginPage,\n+   meta: { needsAuth: false }\n  },\n}\n```\n\n```xml\n\u003c!-- anywhere in your templates --\u003e\n\u003cLabel :text=\"$navigator.route.meta.needsAuth\" /\u003e\n```\n```js\n// or in any vue component\nexport default {\n  methods: {\n    doStuff() {\n      if(this.$navigator.route.meta.needsAuth) {\n        // do stuff\n      }\n    }\n  }\n}\n```\n\n## Getting the current path\n\n```js\n// logs the current path in the default navigator\nconsole.log(this.$navigator.path)\n\n// logs the current path in the second navigator (See Multiple Navigators section for more details)\nconsole.log(this.$navigator.paths.second)\n```\n\n## Navigating\n\nThis package provides 2 methods for navigation, `$navigator.navigate` and `$navigator.back`\n\n`$navigator.navigate(to, options)` is used for all forward navigation\n * `to` is the path to navigate to (ex.: `/home`)\n * `options` is an optional object, which accepts all options supported  by [Manual Routing](https://nativescript-vue.org/en/docs/routing/manual-routing/#navigateto)\n \nFor example, given you are on a Login page, and successfully log in you would navigate to the Home page with\n```js\nthis.$navigator.navigate('/home', { clearHistory: true })\n```\nNote that we used `clearHistory: true` to prevent the back button from going back to the login page.\n\n`$navigator.back(options, backstackEntry)` is an alias to [`$navigateBack`](https://nativescript-vue.org/en/docs/routing/manual-routing/#navigatebackoptions-backstackentry--null)\n\n# Multiple Navigators\n\nIt is possible to use multiple `\u003cNavigator\u003e` elements by providing each new Navigator with a unique `id`. \n\n```vue\n\u003ctemplate\u003e\n  \u003c!-- this is the default navigator and can omit the id --\u003e\n  \u003cNavigator /\u003e   \n  \u003c!-- shows the current path of the default navigator --\u003e\n  \u003cLabel :text=\"$navigator.path\" /\u003e\n\n  \u003c!-- this is the second navigator and it MUST have a unique id --\u003e\n  \u003cNavigator id=\"second\" /\u003e \n  \u003c!-- shows the current path of the second navigator --\u003e\n  \u003cLabel :text=\"$navigator.paths.second\" /\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  export default {\n    methods: {\n      someMethod() {\n        // navigate the default Navigator\n        this.$navigator.navigate('/new-path')\n        // navigate the second default Navigator by specifying the frame option\n        this.$navigator.navigate('/new-path', { frame: 'second' })\n\n\n        // navigate back the default Navigator\n        this.$navigator.back()\n        // navigate back the second Navigator\n        this.$navigator.back({ frame: 'second' })\n      }\n    }    \n  }\n\u003c/script\u003e\n```\n\n# Navigator Modals\n\n```ts\ntype ModalOptions = { id: string } \u0026 ShowModalOptions\nthis.$navigator.modal(path: string, options: ModalOptions);\n```\n\nThe default id for modal navigators is `modalNavigator` but can be changed by passing an `id` inside the ModalOptions. \n\n```js\n// use the default id for the modal\nthis.$navigator.modal('/path', { fullscreen: true })\n// to navigate the modal to '/other'\nthis.$navigator.navigate('/other', { frame: 'modalNavigator' })\n\n// use a different id for the modal\nthis.$navigator.modal('/path', { fullscreen: true, id: 'myModal' })\n// to navigate the myModal modal to '/other'\nthis.$navigator.navigate('/other', { frame: 'myModal' })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-vue%2Fnativescript-vue-navigator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnativescript-vue%2Fnativescript-vue-navigator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-vue%2Fnativescript-vue-navigator/lists"}