Guide · Open source
How to use vue-router: setup, commands and what to know in 2025
Updated · written with AI from the project's own documentation and checked against our catalogue data
vue-router is the official router for Vue 2 web apps. It switches between pages or views based on the URL without reloading the whole page. This guide walks through the setup commands from the project README, the prerequisites, and the end-of-life notice you need to check before using it on any new work.
Quick start
- 1Confirm your stack. Check that your app uses Vue 2 and vue-router 3. If it uses Vue 3, use Vue Router 4 from vuejs/router instead.
- 2Install prerequisites. Install Node.js and Yarn, as listed in the README.
- 3Install dependencies. Run yarn in the repository folder to install development dependencies.
- 4Build the dist files. Run yarn build to create the dist files.
- 5Run the examples. Run yarn dev and open localhost:8080 to view the examples.
- 6Read the docs and plan a migration. Use the v3 documentation for the current code, and plan a move to Vue Router 4 because this version has reached end of life.
What vue-router does in a Vue 2 app
vue-router is a library that lets a Vue 2 web app change which page or view is shown based on the URL. The user moves around the app without the whole page reloading.
The project is MIT licensed and written in JavaScript. Its README describes it as the official router for Vue 2.
Check the version before you start
The README says this repository is vue-router 3.0, which works only with Vue 2.0, and that both Vue 2 and this router have reached end of life. Maintainers of projects that already use vue-router 3 can use this guide to read and debug existing code.
For new projects, the README points to Vue Router 4 for Vue 3, which lives in a separate repository (vuejs/router). The README also links a 1.x branch for the older 1.0 router.
- Existing Vue 2 app using vue-router 3: this guide applies.
- New project or Vue 3 app: use vuejs/router (Vue Router 4) instead.
- Anyone needing future bug fixes or security updates: the README indicates end of life, so plan a migration.
Prerequisites
The README lists Node.js and Yarn as the tools needed to work with the repository. Install both before running the commands below.
- Node.js
- Yarn
Install dependencies and build the project
To work on the repository locally, install the development dependencies with yarn. Then build the dist files with the build script. The README lists these as the first two development steps.
# install deps
yarn
# build dist files
yarn buildRun the examples locally
The README says you can play with the examples in the examples folder. Run the dev script to serve them at localhost:8080, then open that address in your browser.
The README also lists yarn test for linting and running all tests, and yarn docs to serve the docs at localhost:8080.
# serve examples at localhost:8080
yarn devFind the documentation
The README links to the vue-router 3 documentation at http://v3.router.vuejs.org. Use it to learn the router API that this version provides.
For questions and support, the README points to the Discord chat server and the official Vue forum. The issue list is reserved for bug reports and feature requests.
What people use it for
- Reading and debugging a legacy Vue 2 codebase that uses vue-router 3
- Running the bundled examples at localhost:8080 to see how routing is set up
- Building the dist files to check the library in a local environment
- Planning a migration of a Vue 2 app toward a newer router
Frequently asked questions
Is vue-router free to use?
Yes. The README states that vue-router is an MIT-licensed open source project. The MIT licence text is linked in the README.
What are the requirements for vue-router?
The README lists Node.js and Yarn as prerequisites for working with the repository. The library itself works only with Vue 2, according to the README.
Does vue-router work with Vue 3?
No. The README says this version works only with Vue 2.0. For Vue 3, the README points to Vue Router 4 in the vuejs/router repository.
Is vue-router 3 still supported?
The README says vue-router 3.0 and Vue 2 have reached end of life. That means you should not expect future bug fixes or security updates from this version.
What are the alternatives to vue-router?
The closest alternative named in the source is Vue Router 4 (vuejs/router), which is the README's recommended router for Vue 3 projects.
How do I run the vue-router examples?
Install dependencies with yarn, then run yarn dev. The README says the examples are served at localhost:8080.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use vue-router only if you maintain an existing Vue 2 app that already depends on it, or you need to read its code while migrating. For any new project or Vue 3 app, pick Vue Router 4 from vuejs/router, since the README says this version has reached end of life.
Install options & downloads