View Transition API (Nuxt)
When View Transitions mode is on, FlyvaLink wraps navigation in the browser’s document.startViewTransition API. The old and new views participate in a single cross-fade (and you can assign view-transition-name to elements for shared-element–style effects).
Adapter sequence (Nuxt)
FlyvaLink drives startViewTransition and sets vt active. page:start / page:finish short-circuit Flyva’s normal leave/enter when isVtActive(). page:finish calls resolveDomSwap so the VT callback can proceed.
Requirements
- A browser that supports the View Transitions API (check with
supportsViewTransitions()from@flyva/shared). - View Transitions enabled in Flyva module config (below).
Enable in the app
Module options in nuxt.config:
export default defineNuxtConfig({
modules: ['@flyva/nuxt'],
flyva: {
viewTransition: true,
},
});Do not enable Nuxt’s built-in app.viewTransition at the same time as flyva.viewTransition - the module prints a warning; pick one system (Flyva’s integration or Nuxt’s global VT) so only one wraps navigations.
Transition object
Optional fields on PageTransition:
| Field | Purpose |
|---|---|
viewTransitionNames | Record<string, string> or (context) => Record<string, string> mapping pseudo-element names to CSS selectors. Flyva sets element.style.viewTransitionName for each match before the transition snapshot. |
animateViewTransition | (vt, context) => Promise<void> - runs after vt.ready if you need custom work alongside the default transition. |
During the navigation, context.viewTransition is the ViewTransition instance (see PageTransitionContext in @flyva/shared).
Flow (simplified)
- User clicks
FlyvaLink;prepareruns as usual. startViewTransitionis called; inside the callback the app navigates and Flyva coordinates DOM swap resolution (resolveDomSwap).- If
viewTransitionNamesis set, names are applied (and cleared afterfinished). - If
animateViewTransitionexists, it runs aftervt.ready. - When finished, cleanup runs and internal VT state resets.
concurrent: true has no effect while View Transitions mode is active (the manager warns in development).
Helpers (@flyva/shared)
supportsViewTransitions()— feature detectapplyViewTransitionNames(names, context)— resolve map or callback, assign names, return map for later cleanupclearViewTransitionNames(resolvedMap)— clear assigned names
CSS for ::view-transition-old(root), ::view-transition-new(root), and named groups follows standard MDN documentation.
Related
- Transition modes — how VT fits next to JS hooks and CSS mode
- Writing transitions
- @flyva/shared API — types and
view-transitionexports