Skip to content
Source
Sign inSign up
TanStack/router

packages/vue-router

README.md

TanStack Vue Router

TanStack Vue Router

πŸ€– Type-safe router w/ built-in caching & URL state management for Vue!

#TanStack semantic-release Join the discussion on Github Best of JS

Visit tanstack.com/router for docs, guides, API and more!

File-Based Routing Conventions

Suffix/PatternPurpose
.route.tsRoute configuration (loader, validateSearch, head, etc.)
.component.vueThe component rendered for the route
.errorComponent.vueError boundary component for the route
.notFoundComponent.vueNot found component for the route
.lazy.tsLazy-loaded route configuration
_layout prefixLayout routes that wrap child routes
_ suffix (e.g., posts_.$postId)Unnested routes (break out of parent layout)
(groupName) directoryRoute groups (organizational, don't affect URL)
$paramDynamic route parameters

Examples from e2e/basic-file-routes/ project

src/routes/
β”œβ”€β”€ __root.ts                   # Root route config
β”œβ”€β”€ __root.component.vue        # Root layout component
β”œβ”€β”€ __root.notFoundComponent.vue # Global not found component
β”œβ”€β”€ index.route.ts              # "/" route config
β”œβ”€β”€ index.component.vue         # "/" component
β”œβ”€β”€ posts.route.ts              # "/posts" route config
β”œβ”€β”€ posts.component.vue         # "/posts" layout component
β”œβ”€β”€ posts.index.component.vue   # "/posts" index component
β”œβ”€β”€ posts.$postId.route.ts      # "/posts/:postId" route config
β”œβ”€β”€ posts.$postId.component.vue # "/posts/:postId" component
β”œβ”€β”€ posts.$postId.errorComponent.vue  # Error boundary for post
β”œβ”€β”€ posts_.$postId.edit.route.ts      # "/posts/:postId/edit" (unnested)
β”œβ”€β”€ (group)/                    # Route group (no URL impact)
β”‚   β”œβ”€β”€ _layout.route.ts        # Layout for group
β”‚   β”œβ”€β”€ _layout.component.vue
β”‚   └── inside.component.vue    # "/inside"
└── λŒ€ν•œλ―Όκ΅­.component.vue        # Unicode routes supported