{"slug":"capgo-transitions","title":"capgo-transitions","summary":"Adds native-feeling iOS/Android push, pop and root page transitions to Capacitor apps with @capgo/capacitor-transitions (Cap-go/capacitor-transitions, v9.x for Capacitor 9, v8.x for Capacitor 8). Web-only library, no native code - custom elements (`cap-router-outlet`, `cap-page`,","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-05T18:17:11.711Z","repo":{"url":"https://github.com/Cap-go/capgo-skills","stars":79,"forks":4,"license":"MIT","updatedAt":"2026-12-05T16:44:30Z"},"bodyHtml":"<hr>\n<h2>name: capgo-transitions\ndescription: Adds native-feeling iOS/Android push, pop and root page transitions to Capacitor apps with @capgo/capacitor-transitions (Cap-go/capacitor-transitions, v9.x for Capacitor 9, v8.x for Capacitor 8). Web-only library, no native code - custom elements (<code>cap-router-outlet</code>, <code>cap-page</code>, <code>cap-header</code>, <code>cap-content</code>, <code>cap-footer</code>) plus helpers for React (React Router, TanStack Router, Next.js static export), Vue (Vue Router, Nuxt), Svelte/SvelteKit, Solid, Angular and vanilla JS. Covers <code>setDirection</code> / <code>setNavigation</code> before router calls, interactive iOS edge swipe-back (<code>swipe-gesture</code>), page caching (<code>keep-in-dom</code>, <code>max-cached</code>), reduced-motion crossfade, focus management, optional View Transitions API. Use when a non-Ionic Capacitor app swaps pages with no animation or feels like a website when navigating, or when adding swipe-back. Do not use for native navbar/tabbar (capgo-native-navigation), bottom sheets/drawers (capgo-sheets), or Ionic's built-in ion-router-outlet animations (ionic-design).</h2>\n<h1>Capgo Page Transitions</h1>\n<p><code>@capgo/capacitor-transitions</code> gives Ionic-quality page transitions without Ionic's design system. It is a web-only package (custom elements + thin framework helpers), so there is nothing to <code>cap sync</code> and no Capacitor peer dependency.</p>\n<h2>When to Use</h2>\n<p>TRIGGER when:</p>\n<ul>\n<li>A Capacitor app built with React, Vue, Svelte, Solid, Angular, Next.js, Nuxt, SvelteKit, TanStack or vanilla JS swaps routes instantly and should push/pop like a native app</li>\n<li>The user wants iOS-style slide-in/slide-out or Android-style rise/fade between pages</li>\n<li>The user wants the iOS edge swipe-back gesture in a WebView app</li>\n<li>Router <code>replace</code> / onboarding-done / logout flows must reset the back stack but still animate</li>\n<li>The package <code>@capgo/capacitor-transitions</code> or tags <code>cap-router-outlet</code> / <code>cap-page</code> appear in the code</li>\n</ul>\n<p>Do not use:</p>\n<ul>\n<li>Native navigation bar or tab bar owned by the native layer: <code>capgo-native-navigation</code> (it combines with this skill; see Patterns)</li>\n<li>Bottom sheets, drawers, modal sheets: <code>capgo-sheets</code></li>\n<li>Ionic apps using <code>ion-router-outlet</code> / <code>ion-nav</code>: those already animate; use <code>ionic-design</code></li>\n<li>Sticky hover, tap highlight, overscroll bounce, input zoom: <code>capacitor-native-feel</code></li>\n<li>Notch / status bar overlap: <code>safe-area-handling</code></li>\n</ul>\n<p>Default recommendation: for a non-Ionic Capacitor app that needs push/pop page transitions, use this package rather than hand-written CSS transitions or a framework transition component.</p>\n<h2>Install</h2>\n<pre><code>npm install @capgo/capacitor-transitions@^9   # Capacitor 9\nnpm install @capgo/capacitor-transitions@^8   # Capacitor 8\n</code></pre>\n<p>Entry points (from <code>package.json</code> <code>exports</code>): <code>@capgo/capacitor-transitions</code> (core + web components), <code>/react</code>, <code>/vue</code>, <code>/svelte</code>, <code>/solid</code>. Each adapter subpath imports and registers the custom elements. Angular and vanilla use the root entry.</p>\n<p>Layout prerequisite: the outlet sets itself to <code>height: 100%</code>, so every ancestor must have a height (<code>html, body, #root { height: 100%; }</code>).</p>\n<h2>Quick Start</h2>\n<p>Vanilla / any framework (markup):</p>\n<pre><code>&lt;cap-router-outlet platform=\"auto\" swipe-gesture=\"auto\"&gt;\n  &lt;cap-page&gt;\n    &lt;cap-header slot=\"header\"&gt;&lt;h1&gt;Inbox&lt;/h1&gt;&lt;/cap-header&gt;\n    &lt;cap-content slot=\"content\"&gt;...&lt;/cap-content&gt;\n    &lt;cap-footer slot=\"footer\"&gt;&lt;nav&gt;Tabs&lt;/nav&gt;&lt;/cap-footer&gt;\n  &lt;/cap-page&gt;\n&lt;/cap-router-outlet&gt;\n</code></pre>\n<pre><code>import '@capgo/capacitor-transitions';\nconst outlet = document.querySelector('cap-router-outlet')!;\nawait outlet.push(pageEl);                          // forward slide\nawait outlet.pop();                                 // back slide\nawait outlet.setRoot(homeEl, { direction: 'forward' }); // reset stack, forward slide\n</code></pre>\n<p>React (React Router):</p>\n<pre><code>import { setupRouterOutlet, setupPage, setDirection, setNavigation } from '@capgo/capacitor-transitions/react';\n\nfunction App() {\n  const outletRef = useRef&lt;HTMLElement&gt;(null);\n  useEffect(() =&gt; {\n    if (outletRef.current) setupRouterOutlet(outletRef.current, { platform: 'auto', swipeGesture: 'auto' });\n  }, []);\n  return (\n    &lt;cap-router-outlet ref={outletRef}&gt;\n      &lt;Routes&gt;\n        &lt;Route path=\"/\" element={&lt;Home /&gt;} /&gt;\n        &lt;Route path=\"/details/:id\" element={&lt;Details /&gt;} /&gt;\n      &lt;/Routes&gt;\n    &lt;/cap-router-outlet&gt;\n  );\n}\n// in a page: setDirection('forward'); navigate(`/details/${id}`);\n</code></pre>\n<p>Vue (Vue Router) - also add <code>isCustomElement: (tag) =&gt; tag.startsWith('cap-')</code> to the Vue compiler options:</p>\n<pre><code>&lt;script setup lang=\"ts\"&gt;\nimport { ref, onMounted } from 'vue';\nimport { setupRouterOutlet } from '@capgo/capacitor-transitions/vue';\nconst outletRef = ref&lt;HTMLElement | null&gt;(null);\nonMounted(() =&gt; outletRef.value &amp;&amp; setupRouterOutlet(outletRef.value, { platform: 'auto' }));\n&lt;/script&gt;\n&lt;template&gt;\n  &lt;cap-router-outlet ref=\"outletRef\"&gt;&lt;router-view /&gt;&lt;/cap-router-outlet&gt;\n&lt;/template&gt;\n</code></pre>\n<p>Svelte / SvelteKit:</p>\n<pre><code>&lt;script&gt;\n  import { routerOutlet } from '@capgo/capacitor-transitions/svelte';\n  import '@capgo/capacitor-transitions';\n&lt;/script&gt;\n&lt;cap-router-outlet use:routerOutlet={{ platform: 'auto' }}&gt;&lt;slot /&gt;&lt;/cap-router-outlet&gt;\n</code></pre>\n<p>Solid, Angular, Next.js, Nuxt, TanStack: see <a href=\"references/frameworks.md\">references/frameworks.md</a>.</p>\n<p>Every routed page renders one <code>&lt;cap-page&gt;</code> as the direct child of the outlet (Angular renders its component host element instead).</p>\n<h2>Core Concepts</h2>\n<ul>\n<li><strong>Outlet observes the DOM.</strong> <code>cap-router-outlet</code> uses a MutationObserver. When the router adds a new child, it animates from the current page to the new one. If the router removes the old page first, the outlet re-inserts it temporarily so the leaving animation is visible.</li>\n<li><strong>Direction is an intent set before navigating.</strong> <code>setDirection(d)</code> writes <code>data-direction</code> on every outlet; the next added page consumes it. Without an intent, the outlet infers: <code>popstate</code> / History index decrease / a URL already in its history =&gt; <code>back</code>; same URL =&gt; <code>none</code>; otherwise <code>forward</code>. A <code>data-direction</code> attribute on the page element wins over the outlet's.</li>\n<li><strong>Stack action vs. animation.</strong> <code>setNavigation(action, direction?)</code> separates what happens to the stack (<code>forward</code> push, <code>back</code> pop, <code>root</code> clear, <code>none</code> replace top) from the animation. <code>setNavigation('root', 'forward')</code> slides forward but leaves no back entry (swipe-back disabled).</li>\n<li><strong>Directions:</strong> <code>forward</code> (iOS: slide in from right; Android: rise 40px + fade in), <code>back</code> (reverse), <code>root</code> (fade), <code>none</code> (instant).</li>\n<li><strong>Platform:</strong> <code>platform=\"auto\"</code> picks by user agent (iPhone/iPad/iPod =&gt; ios, Android =&gt; android, else ios). Defaults: iOS 540ms <code>cubic-bezier(0.32, 0.72, 0, 1)</code>; Android 280ms forward / 200ms back.</li>\n<li><strong>Pinned chrome.</strong> On iOS, header and footer of the moving pages are counter-translated so bars stay put while page bodies slide; direct toolbar children (<code>h1</code>-<code>h3</code>, <code>button</code>, <code>a</code>, <code>.toolbar &gt; *</code>, <code>[role=\"toolbar\"] &gt; *</code>, <code>[data-cap-toolbar-item]</code>) slide and fade like UIKit titles.</li>\n<li><strong>Caching.</strong> <code>keep-in-dom</code> (default <code>true</code>) keeps up to <code>max-cached</code> (default 10) previous pages in the DOM.</li>\n<li><strong>Each outlet owns its own <code>TransitionController</code>.</strong> <code>initTransitions()</code> from an adapter creates a separate controller that outlets do not read. Configure outlets via attributes / <code>setupRouterOutlet</code>, and use <code>outlet.getController().configure({...})</code> for <code>easing</code>, <code>useViewTransitions</code>, <code>respectReducedMotion</code>, <code>manageFocus</code>.</li>\n</ul>\n<p>Full API: <a href=\"references/api.md\">references/api.md</a>. Gesture, reduced motion, focus, View Transitions internals: <a href=\"references/behavior.md\">references/behavior.md</a>.</p>\n<h2>Reference Map</h2>\n<table>\n<thead>\n<tr>\n<th>Load</th>\n<th>When</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><a href=\"references/api.md\">references/api.md</a></td>\n<td>You need exact attributes, methods, helper signatures, exported core functions, types or constants</td>\n</tr>\n<tr>\n<td><a href=\"references/frameworks.md\">references/frameworks.md</a></td>\n<td>Wiring a specific router: React Router, TanStack Router/Start, Next.js, Vue Router, Nuxt, Svelte, SvelteKit, Solid Router, Angular Router, vanilla History</td>\n</tr>\n<tr>\n<td><a href=\"references/behavior.md\">references/behavior.md</a></td>\n<td>Debugging direction inference, swipe-back thresholds and ignored targets, reduced motion, focus management, View Transitions, <code>@capgo/native-navigation</code> pairing</td>\n</tr>\n</tbody>\n</table>\n<h2>Patterns</h2>\n<p><strong>Push / pop with a router.</strong> Call the helper right before the router call, every time:</p>\n<pre><code>setDirection('forward'); navigate(`/item/${id}`);\nsetDirection('back');    navigate(-1);            // or history.back()\nsetNavigation('root', 'forward'); navigate('/home', { replace: true }); // onboarding done\nsetNavigation('root', 'root');    navigate('/login', { replace: true }); // logout, fade\n</code></pre>\n<p>Wrap once with <code>createTransitionNavigate(navigate)</code> =&gt; <code>go('/path')</code>, <code>go('/', 'back')</code> (passes only <code>to</code>; use the helpers directly for router options such as <code>replace</code>).</p>\n<p><strong>Tab switches without animation.</strong> Tabs are siblings, not a stack. Use <code>setNavigation('root', 'none')</code> before switching to a tab root: instant swap, back stack cleared, swipe-back cannot return to the previous tab. <code>setDirection('none')</code> alone is not enough: the controller still pushes the page onto its stack.</p>\n<p><strong>Modal-style screens.</strong> The package has no modal/present transition; <code>TransitionConfig.enterKeyframes</code>, <code>leaveKeyframes</code>, <code>targets</code> and <code>RouterOutletOptions.animation</code> are declared in types but not used by the 9.0.1 source. Use <code>capgo-sheets</code> for sheets, or <code>setNavigation('forward', 'root')</code> for a fade-in page that still keeps a back entry.</p>\n<p><strong>Swipe-back.</strong> <code>swipe-gesture=\"auto\"</code> (default) enables the 50px left-edge gesture only when <code>Capacitor.isNativePlatform()</code> and platform is <code>ios</code>. Force with <code>true</code> / <code>false</code> or <code>outlet.setSwipeGesture(...)</code>. On commit the outlet calls <code>window.history.back()</code> (when <code>history.length &gt; 1</code>) and skips the second animation, so the router must render the previous route on <code>popstate</code>. Mark horizontal carousels or sliders with <code>data-swipe-back-ignore</code>.</p>\n<p><strong>Native bars (<code>@capgo/native-navigation</code>).</strong> Keep the native navbar out of <code>&lt;cap-header&gt;</code>; use <code>&lt;cap-content slot=\"content\" fullscreen&gt;</code> and pad with <code>var(--cap-native-navigation-top)</code> / <code>var(--cap-native-navigation-bottom)</code>. On the native <code>navbarBack</code> event call <code>setDirection('back')</code> then <code>router.back()</code>.</p>\n<p><strong>Lifecycle.</strong> <code>setupPage(el, { onWillEnter, onDidEnter, onWillLeave, onDidLeave })</code> (Svelte: <code>use:page={...}</code>) listens for <code>cap-will-enter</code>, <code>cap-did-enter</code>, <code>cap-will-leave</code>, <code>cap-did-leave</code> on <code>&lt;cap-page&gt;</code> and returns a cleanup function. See trap below before relying on them.</p>\n<h2>Traps</h2>\n<ul>\n<li><strong>Lifecycle events may never fire.</strong> In the 9.0.1 source, <code>cap-page</code> dispatches <code>cap-*-enter/leave</code> only from its own <code>willEnter()</code>/<code>didEnter()</code>/<code>willLeave()</code>/<code>didLeave()</code> methods, and neither the outlet nor the controller calls them; controller hooks run only for <code>controller.registerLifecycle(pageId, ...)</code> with the internal page id. Verify events on device before depending on them; for data loading use the framework's mount hooks or route guards.</li>\n<li><strong>Forgetting <code>setDirection('back')</code> on in-app back buttons</strong> that call <code>navigate('/')</code> makes the outlet see a new URL and slide forward. Prefer <code>navigate(-1)</code> / <code>history.back()</code>, or always set the direction.</li>\n<li><strong>Double animation.</strong> Do not also wrap pages in Vue <code>&lt;Transition&gt;</code>, Nuxt <code>pageTransition</code>, Svelte <code>transition:</code>, React Router <code>viewTransition</code>, SvelteKit <code>onNavigate</code> + <code>startViewTransition</code>, or CSS route animations. One system only. <code>useViewTransitions</code> (off by default) is a second path; enable it only if you removed the others.</li>\n<li><strong>Scroll restoration.</strong> Pages scroll inside <code>cap-content</code> (<code>overflow: auto</code>), not the window, so router scroll restoration (<code>ScrollRestoration</code>, Vue Router <code>scrollBehavior</code>, <code>window.scrollTo</code>) does nothing. Most routers mount a fresh element on back, and the outlet removes the stale cached one, so the old scroll offset is lost. Persist <code>contentEl.scrollTop</code> per route yourself (<code>cap-content</code> emits bubbling <code>cap-scroll</code> with <code>{ x, y }</code> and has <code>saveScrollPosition()</code>, <code>restoreScrollPosition(pos)</code>, <code>scrollToTop()</code>).</li>\n<li><strong>Fixed headers.</strong> During a transition the page element is transformed, so any <code>position: fixed</code> element inside <code>cap-page</code> becomes relative to the moving page and slides with it. Put bars in <code>cap-header</code>/<code>cap-footer</code> slots; keep truly global fixed UI outside the outlet.</li>\n<li><strong><code>fullscreen</code> only sets <code>data-fullscreen=\"true\"</code></strong> on <code>cap-content</code>; you write the CSS that lets content run under the header.</li>\n<li><strong>Reduce Motion.</strong> With <code>prefers-reduced-motion: reduce</code>, slides become a 200ms crossfade (default <code>respectReducedMotion: true</code>); interactive swipe still tracks the finger. Do not add your own reduced-motion override on top. Opt out only with <code>outlet.getController().configure({ respectReducedMotion: false })</code>.</li>\n<li><strong><code>duration</code> 0 does not disable animation.</strong> The controller treats 0 as \"use platform default\", and the Vue/Svelte/Solid helpers skip falsy durations. Use direction <code>none</code>.</li>\n<li><strong>Vue / Nuxt</strong> without <code>isCustomElement</code> for <code>cap-*</code> warns \"Failed to resolve component\" and may treat tags as components.</li>\n<li><strong>React TypeScript</strong> errors on <code>cap-router-outlet</code> in JSX: add <code>src/capgo-transitions.d.ts</code> containing <code>import '@capgo/capacitor-transitions/react';</code> and include it in <code>tsconfig.json</code>.</li>\n<li><strong>SSR frameworks.</strong> Custom elements need the browser. Use static export (Next.js <code>output: 'export'</code>, SvelteKit <code>adapter-static</code>, Nuxt <code>ssr: false</code>) as Capacitor requires anyway, and call <code>initTransitions</code> only on the client.</li>\n<li><strong>Background flash.</strong> <code>cap-page</code> paints <code>var(--cap-page-background, Canvas)</code>; set <code>--cap-page-background</code> to your app background or pages look white/black mid-slide.</li>\n</ul>\n<h2>Verify on Device</h2>\n<ol>\n<li><code>npm run build &amp;&amp; npx cap copy</code> (no <code>cap sync</code> needed for this package alone), run on a physical iPhone and an Android device.</li>\n<li>Navigate forward, back via in-app button, back via Android system back, and (iOS) swipe from the left edge: each must animate once in the right direction, with no flash and no double slide.</li>\n<li>Swipe halfway and release slowly: page springs back. Flick quickly: completes. Swipe on a carousel: does not trigger back.</li>\n<li>Reset flows (<code>setNavigation('root', ...)</code>): after landing, edge swipe must do nothing.</li>\n<li>Turn on iOS Settings &gt; Accessibility &gt; Motion &gt; Reduce Motion (Android: Remove animations): navigation becomes a crossfade.</li>\n<li>In Safari Web Inspector / <code>chrome://inspect</code>, check <code>document.querySelector('cap-router-outlet').stackLength</code> and <code>.canGoBack</code> match the visible history.</li>\n</ol>\n<h2>Resources</h2>\n<ul>\n<li>Docs: <a href=\"https://capgo.app/docs/plugins/transitions/\">https://capgo.app/docs/plugins/transitions/</a></li>\n<li>Source and examples (React, Vue, Angular, Svelte, SvelteKit, Solid, TanStack, Next.js, Nuxt): <a href=\"https://github.com/Cap-go/capacitor-transitions\">https://github.com/Cap-go/capacitor-transitions</a></li>\n<li>npm: <a href=\"https://www.npmjs.com/package/@capgo/capacitor-transitions\">https://www.npmjs.com/package/@capgo/capacitor-transitions</a></li>\n</ul>\n","files":[{"path":"metadata.json","sizeBytes":1317,"isText":true},{"path":"references/api.md","sizeBytes":10689,"isText":true},{"path":"references/behavior.md","sizeBytes":7227,"isText":true},{"path":"references/frameworks.md","sizeBytes":12481,"isText":true},{"path":"SKILL.md","sizeBytes":14661,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-05T18:17:57.886601Z","sha256":"4840F464727FDC1FCCB608260492FACC89A88FD42E25B457B453AE3506BC62D5","sizeBytes":18608},"review":null,"source":{"repositoryUrl":"https://github.com/Cap-go/capgo-skills","path":"plugins/capacitor-ui/skills/capgo-transitions","license":"MIT","commit":"76462e3a0041ee8dd0d370c344d9fd3ae2c29cdb","subtreeSha":"D0450315359CA0FF9BB696972D123A049DD30BEB1720F0118A00A6ECB1C31A9B","lastSyncedAt":"2026-12-05T18:17:06.651351Z"},"reviewedAt":"2026-12-05T18:18:55.503041Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/Cap-go/capgo-skills/tree/main/plugins/capacitor-ui/skills/capgo-transitions"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install cap-go-capgo-skills@llmmart"},{"target":"git","command":"git clone https://github.com/Cap-go/capgo-skills.git"}]}