Question: I want to get previous page link or url in `vue-router`. Like a this. How to do it?

```
const link = this.$router.getPrevLink(); // function is not exist?
this.$router.push(link);

```

Near concept is `this.$router.go(-1)`.

```
this.$router.go(-1);

```

Answer: 
For Vue 2.6 that works for me:

In-App.vue component when you initialize the VueRouter you can get from and to details as below:

```
export const globalState = Vue.observable({ from: {}, to: {} });
const router = new VueRouter({
    base: '/',
    routes: routes,
    mode: 'history',
    scrollBehavior(to, from, savedPosition) {
        Vue.set(globalState, 'from', from);
        Vue.set(globalState, 'to', to);
        return { x: 0, y: 0 };
    },
});

```

routes are ur routes and each time u navigate to a different URL you will have all from and to routes details.
Then u can import the `globalState` object and use it like that

```
     import { globalState } from './app';
     goBack() {
        const lastPath = globalState.from?.fullPath;
        const currentPath = globalState.to?.fullPath;
        if (lastPath && currentPath !== lastPath) 
           {
              this.$router.push(lastPath);
           } else {
              this.$router.push('another-path');
            }
        }

```
To yank it right out of the $router object, use this in your computed or methods:

```
lastRouteName: function() {
  let returnVal = '';

  const routerStack = this.$router.history.stack;
  const idx = this.$router.history.index;

  if (idx > 0) {
    returnVal = routerStack[idx - 1].name;
  }

  return returnVal;
}

```

That'll return the route name, but you can also return the `.path` or whatever other property if you like.

To inspect the history object, do `console.log(this.$router.history);`