Accessing Router Information

Learn about the router package and how to access it.

Nuxt router is a package that enables any file inside the pages directory to be used as a route or URL. A file name pages/Account.vue will be displayed when we visit yourwebsitename/account. The package also offers many benefits, such as code splitting, which breaks up a large JavaScript bundle into smaller files when a user first visits our app. This can speed up the initial page load, and it then prefetches the file contents of any links when needed.

Nuxt router is based on the Vue.js router package, so most of the code is interchangeable. Here is an example of how we can get the router params with the useRoute composable:

Get hands-on with 1200+ tech skills courses.