{"record":{"id":"2622488ba5414e06","repo":"vuejs/vue-router","slug":"router-addroutes-is-deprecated-and-has-been-remo","errorCode":null,"errorMessage":"router.addRoutes() is deprecated and has been removed in Vue Router 4. Use router.addRoute() instead.","messagePattern":"router\\.addRoutes\\(\\) is deprecated and has been removed in Vue Router 4\\. Use router\\.addRoute\\(\\) instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/router.js","lineNumber":263,"sourceCode":"      normalizedTo: location,\n      resolved: route\n    }\n  }\n\n  getRoutes () {\n    return this.matcher.getRoutes()\n  }\n\n  addRoute (parentOrRoute: string | RouteConfig, route?: RouteConfig) {\n    this.matcher.addRoute(parentOrRoute, route)\n    if (this.history.current !== START) {\n      this.history.transitionTo(this.history.getCurrentLocation())\n    }\n  }\n\n  addRoutes (routes: Array<RouteConfig>) {\n    if (process.env.NODE_ENV !== 'production') {\n      warn(false, 'router.addRoutes() is deprecated and has been removed in Vue Router 4. Use router.addRoute() instead.')\n    }\n    this.matcher.addRoutes(routes)\n    if (this.history.current !== START) {\n      this.history.transitionTo(this.history.getCurrentLocation())\n    }\n  }\n}\n\nfunction registerHook (list: Array<any>, fn: Function): Function {\n  list.push(fn)\n  return () => {\n    const i = list.indexOf(fn)\n    if (i > -1) list.splice(i, 1)\n  }\n}\n\nfunction createHref (base: string, fullPath: string, mode) {\n  var path = mode === 'hash' ? '#' + fullPath : fullPath","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/vuejs/vue-router/blob/680ccc68c506cca9be6207745043245d61fa715a/src/router.js#L245-L281","documentation":"router.addRoutes() was deprecated in Vue Router 3.x and removed in Vue Router 4; vue-router emits this deprecation warning when it is called. The method still works in 3.x (it appends routes and re-runs transitionTo), but code should move to addRoute().","triggerScenarios":"Calling router.addRoutes([...]) at runtime to register routes dynamically — e.g. after login or loading remote config — on a Vue Router 3.5+ install.","commonSituations":"Permission-based dynamic route registration; upgrading codebases from early vue-router 3 to 3.5+/4; documentation/tutorial code predating the addRoute API.","solutions":["Replace addRoutes(routes) with routes.forEach(r => router.addRoute(r))","Prefer addRoute(parentName, route) to attach children under an existing named route","For removal/replacement semantics, use router.removeRoute(name) or addRoute with the same name (Vue Router 4 replaces)","After dynamic registration, navigate/re-resolve if the current route should be re-matched"],"exampleFix":"// before\nrouter.addRoutes(dynamicRoutes)\n// after\ndynamicRoutes.forEach(route => router.addRoute(route))","handlingStrategy":"fallback","validationCode":"if (typeof router.addRoutes === 'function') {\n  // vue-router 3 legacy path\n  router.addRoutes(routes)\n} else if (typeof router.addRoute === 'function') {\n  routes.forEach(r => router.addRoute(r))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Migrate to addRoute()/addRoute(parentName, route) everywhere","Silence by never calling addRoutes in 3.5+ / Vue Router 4 code","Keep a small compat shim (as in validationCode) if supporting both versions"],"tags":["vue-router","deprecation","dynamic-routes","migration"],"backgroundTag":"deprecated-api-usage","analyzedSha":"680ccc68c506cca9be6207745043245d61fa715a","analyzedAt":"2026-09-02T19:19:01.204Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}