Skip to content

Vue RouterThe Official Router for Vue.js

Build Modern SPAs with Confidence

Vue Router Logo

🌟 Why Choose Vue Router?

Vue Router is the official client-side routing solution for Vue.js, designed specifically for building single-page applications (SPAs). It's not just a routing library—it's your essential companion for creating modern web applications.

📊 Performance First

  • Bundle size: ~12KB gzipped
  • Tree-shakable architecture
  • Lazy loading support
  • Zero runtime overhead

🛠️ Developer Experience

  • Full TypeScript support
  • Vue DevTools integration
  • Hot module replacement
  • Comprehensive error messages

🚀 Production Ready

  • Used by Vue.js, GitLab, Adobe
  • Extensive test coverage
  • Backward compatibility
  • Active maintenance

✨ Core Features at a Glance

🛣️ Expressive Route Syntax

Define static and dynamic routes with an intuitive and powerful syntax. Whether it's simple page navigation or complex parameter passing, Vue Router makes it elegant and straightforward.

javascript
// Simple yet powerful route definitions
const routes = [
  { path: '/', component: Home },
  { path: '/user/:id', component: User },
  { path: '/user/:id/posts/:postId', component: UserPost },
  // Catch-all route for 404 pages
  { path: '/:pathMatch(.*)*', component: NotFound }
]

🛑 Fine-grained Navigation Control

Want to perform authentication checks when users navigate? Or remind users to save data before leaving a page? Vue Router's navigation guards give you complete control.

javascript
// Global navigation guard example
router.beforeEach(async (to, from) => {
  // Check if user is authenticated
  if (to.meta.requiresAuth && !isAuthenticated()) {
    return '/login'
  }
})

🧱 Component-based Configuration

Each route corresponds to a component, making your application structure clear and maintainable. Component lazy loading, nested routes, named views—everything feels natural.

javascript
// Lazy loading for better performance
const routes = [
  {
    path: '/dashboard',
    component: () => import('./Dashboard.vue'),
    children: [
      { path: 'analytics', component: () => import('./Analytics.vue') },
      { path: 'settings', component: () => import('./Settings.vue') }
    ]
  }
]

🔌 Flexible History Modes

  • HTML5 History Mode: Clean URLs, SEO-friendly (/user/123)
  • Hash Mode: Best compatibility for all environments (/#/user/123)
  • Memory Mode: Perfect for SSR and testing environments

🎚️ Precise Scroll Control

Take complete control over scroll position during page transitions. Return to top, maintain position, or scroll to specific elements—enhance user experience to the next level.

javascript
const router = createRouter({
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

🌐 Automatic Encoding

Use Unicode characters directly in your code (like "你好"), and Vue Router automatically handles encoding issues.

🚀 Quick Start

Ready to begin your Vue Router journey?

⚡ Get Started in 3 Steps

1

Install

npm install vue-router@4
2

Configure

Define your routes

3

Use

Add RouterView & RouterLink

📚 Learning Path

🎯 Beginner's Guide

  1. Installation - Get up and running in 5 minutes
  2. Basic Concepts - Understand core routing principles
  3. Dynamic Routes - Handle parameters and wildcards
  4. Nested Routes - Build complex layouts
⏱️ Time to complete: 2-3 hours

🔥 Advanced Techniques

⏱️ Time to complete: 4-6 hours

🛠️ Production Ready

⏱️ Time to complete: 3-4 hours

🏆 Why Developers Love Vue Router

"Vue Router increased my SPA development efficiency by 300%!" - Senior Frontend Engineer

  • 🎨 Excellent Developer Experience: Intuitive API design with a gentle learning curve
  • ⚡ Outstanding Performance: Code splitting and lazy loading make your app fly
  • 🔧 Feature Complete: From simple routing to complex scenarios, one library handles all needs
  • 🌍 Active Community: Rich ecosystem with reliable problem-solving support

🎁 Free Learning Resources

📹 Video Tutorials

📚 Documentation

🛠️ Tools & Utilities

🌍 Community & Support

📊 Stats

  • 40k+ GitHub stars
  • 📦 2M+ weekly downloads
  • 🔧 500+ contributors
  • 🌐 20+ languages supported

💎 Sponsor Support

Vue Router's continued development depends on community support:

🥇 Gold Sponsors

Thank you to our gold sponsors for supporting open source!

🥈 Silver Sponsors

Every contribution makes Vue Router better.


🚀 Ready to take your Vue.js applications to the next level?

Vue Router 4 - Built for modern web applications

🚀 Vue Router - 让前端路由变得简单而强大 | 构建现代化单页应用的最佳选择