How to remove hash bang #! from URL with Vue.js and Vue Router?

Sometimes, we want to remove hash bang #! from URL with Vue.js and Vue Router.

In this article, we’ll look at how to remove hash bang #! from URL with Vue.js and Vue Router.

How to remove hash bang #! from URL with Vue.js and Vue Router?

To remove hash bang #! from URL with Vue.js and Vue Router, we can set the VueRouter‘s mode to 'history'.

For instance, we write

const router = new VueRouter({
  mode: "history",
});

to create a VueRouter instance by calling VueRouter with an object with the mode property set to 'history'.

Conclusion

To remove hash bang #! from URL with Vue.js and Vue Router, we can set the VueRouter‘s mode to 'history'.