--- title: RouterView Transitions Always Apply Despite Missing appear Prop impact: LOW impactDescription: Initial page load with RouterView triggers transition animation even without the appear prop due to async navigation type: gotcha tags: [vue3, transition, vue-router, appear, initial-load, navigation] --- # RouterView Transitions Always Apply Despite Missing appear Prop **Impact: LOW** - When using `` with Vue Router's ``, the enter transition animation runs on initial page load even if you haven't added the `appear` prop. This differs from normal Transition behavior where `appear` is required for initial render animations. This happens because Vue Router's navigations are asynchronous, causing the component to mount after the initial render. ## Task Checklist - [ ] Be aware that RouterView transitions always animate on initial load - [ ] If you want NO animation on initial load, you need to handle this explicitly - [ ] Don't add `appear` prop expecting it to change behavior - it's already effectively enabled - [ ] Consider whether initial animation is desired for your UX **Expected Behavior (Normal Transition):** ```vue ``` **RouterView Behavior (Different!):** ```vue ``` ## Why This Happens Vue Router navigations are asynchronous. The sequence is: 1. Vue application mounts with empty RouterView 2. Router resolves the initial route 3. Route component is inserted into RouterView 4. This insertion triggers the enter transition Since the component wasn't present in the initial render and is "inserted" afterward, Vue treats it as a normal enter transition, not an initial render. ## If You Want to Disable Initial Animation ```vue ``` ## Alternative: Use CSS to Skip First Animation ```vue ``` ## Standard RouterView Transition Pattern If you're fine with initial animation (often desired), use the standard pattern: ```vue ``` ```javascript // router.js const routes = [ { path: '/', component: Home }, { path: '/about', component: About, meta: { transition: 'slide' } // Custom transition for this route } ] ``` ## Reference - [Vue Router Transitions](https://router.vuejs.org/guide/advanced/transitions.html) - [Vue.js Transition appear](https://vuejs.org/guide/built-ins/transition.html#transition-on-appear)