Skip to main content
InterviewHubPRO
Section Overview
Q40

Question 40 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

80%
Astro Islands & SSR (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

View Transitions in Astro: Client Router and State Persistence.

senior LevelCode ExampleCLIRoutingSystem Design

In Simple Words: By adding <ViewTransitions /> from astro:transitions into your root layout <head>, Astro transforms multi-page navigation into a single-page app (SPA) experience:

  • It intercepts link clicks, fetches the next page HTML, and morphs the DOM using the browser's native View Transitions API.
  • transition:persist: Keeps an interactive Island component mounted across page navigations (e.g. an audio/video player that continues playing without pausing!).
astro
---
// src/layouts/BaseLayout.astro
import { ViewTransitions } from 'astro:transitions';
---
<html>
  <head>
    <ViewTransitions />
  </head>
  <body>
    <!-- Persistent audio player survives route changes without stopping playback -->
    <AudioPlayer client:load transition:persist />
    <slot />
  </body>
</html>