Web

What Is the View Transitions API? Smooth Page Transitions Explained

Talha Aslan 18 min read

Short answer

What is the View Transitions API, and what does it do?

The View Transitions API is an interface where the browser captures two states of a page and connects them with a CSS animation. It works for changes inside one page and for navigation between two pages on the same site. The default effect is a smooth cross-fade, and you can customize it fully with CSS.

Keep reading for the full details and examples

The View Transitions API is a web standard that lets the browser snapshot the old and new state of a page and play a smooth animation between them on its own. Building that effect once took heavy JavaScript libraries and a single page app. Today you can add it with a few lines of CSS, even on a classic multi page site. In this guide, we cover both transition types, CSS examples, browser support, accessibility and performance, step by step.

In other words, you no longer need to turn your site into an app to get smooth page transitions. The browser takes a static picture of the old view, prepares the new view live, then layers and animates the two. Moreover, browsers without support simply keep working without the animation, so the API fits progressive enhancement perfectly.

Which two transition types does the View Transitions API offer?

The API covers two separate scenarios, and each one needs a different setup. Knowing the difference up front saves you hours spent reading the wrong documentation.

FeatureSame-document transitionCross-document transition
Use caseContent changes without a page load (tabs, filters, galleries)The visitor follows a link to another page
How it startsA JavaScript call to document.startViewTransition()A CSS @view-transition rule on both pages
Code neededA small piece of JavaScriptOften CSS only
Origin requirementNone, it stays inside one pageBoth pages must share an origin
Best forSingle page apps, interactive componentsBusiness sites, blogs, ecommerce
In unsupported browsersThe change applies without animationA normal page load happens

Most business websites use a multi page structure. Therefore we set up cross-document transitions most often. Still, same-document transitions work very well for tabs, filters and galleries.

Choosing the right type is part of planning the site, not an afterthought. That is why, in our web design services, we decide on transitions together with information architecture and speed goals.

How do same-document view transitions work?

The Chrome for Developers guide to same-document view transitions describes the flow: you call document.startViewTransition() with a callback that updates the DOM. The browser captures the old state, runs your callback, captures the new state and animates between them through pseudo-elements.

If your callback returns a promise, the browser holds the transition until that promise resolves. That helps, for example, when you fetch new content from the server first and then start the transition. However, keep that wait short; otherwise the visitor clicks and stares at a frozen screen.

The same guide recommends feature detection too. If the browser does not know document.startViewTransition, you call your DOM update function directly. Then older browsers still work; they just skip the animation. In short, the transition is a decorative layer, and functionality should never depend on it.

How do you create smooth page transitions between pages?

To enable transitions on a multi page site, the Chrome guide to cross-document view transitions says both the page you leave and the page you open need this CSS rule: @view-transition { navigation: auto; }. That is it. When both pages include the rule, link clicks within the same site play the default cross-fade automatically.

The guide also spells out which navigations qualify. Back and forward moves count, along with navigations not started through the browser interface. On the other hand, typing in the address bar, opening a bookmark and reloading the page fall outside the scope. So visitors see the transition when they click a link, not when they type an address.

The best part of this approach is how safely you can add it to an existing site. On a site that shares one stylesheet, placing the rule there covers every page at once. After that, you name specific elements to build richer effects.

What does the same-origin requirement mean for cross-document transitions?

According to the Chrome guide, cross-document transitions work only when both pages share the same origin. An origin combines the scheme, hostname and port. For example, two pages inside example.com can transition, but www.example.com and example.com cannot, because they count as different origins.

That rule has practical consequences. If your site hosts a section such as the blog on its own subdomain, transitions between the main site and the blog will not run. Similarly, inconsistent redirects between www and non-www versions make transitions appear on some clicks and vanish on others.

Therefore, before setting up transitions, you make sure the site runs on one canonical origin. That cleanup also helps SEO: one origin, one canonical address and consistent redirects send a clear signal to search engines and visitors alike.

How does view-transition-name animate elements separately?

In the default transition, the whole page fades as one piece. For a more striking result, you give specific elements a name with the view-transition-name property. The MDN View Transition API documentation explains that this property moves an element into its own snapshot so it can animate separately from the rest of the page.

The classic example is a product card. If the product image on the list page and the large image on the detail page share the same name, the browser glides the image from its small position to its large one. The visitor follows the product they tapped with their eyes.

However, one rule is critical. The Chrome same-document guide stresses that each name must identify only one element at a time; if two rendered elements share a name, the browser skips the transition entirely. On list pages, you therefore assign the name only to the clicked item, not to every card. To style many elements the same way, you use the view-transition-class property instead.

What are the transition pseudo-elements, and how do you customize them with CSS?

During a transition, the browser builds a temporary tree of layers on top of the page. The MDN documentation lists the parts of that tree:

  • ::view-transition: the root overlay that holds all transitions and sits above the page.
  • ::view-transition-group(): the root of a single named transition, where position and size animate.
  • ::view-transition-image-pair(): the container that holds the old and new views.
  • ::view-transition-old(): a static snapshot of the old view.
  • ::view-transition-new(): a live representation of the new view.

To customize, you write ordinary CSS animations for these pseudo-elements. For example, you define a slide-out animation for ::view-transition-old(root) and a slide-in from the right for ::view-transition-new(root). Duration, easing and delay are entirely up to you.

According to the Chrome guide, the default behavior fades the old view out while the new view fades in; named groups also animate position, width and height by default. As a result, in most cases you only decide the duration and which elements move on their own.

How do you set up your first transition with the View Transitions API?

To add your first transition to a multi page business site, follow this order. We describe the code at concept level, and your developer can drop it into your stylesheet easily.

  1. Confirm the site runs on one origin and the www redirect stays consistent.
  2. Add @view-transition { navigation: auto; } to the shared stylesheet, then click between two pages to see the default fade.
  3. Give a fixed name to elements that stay the same on every page, such as the header and logo, so they hold still during the transition.
  4. Where a card should match a detail view, give the clicked element and its counterpart on the target page the same name.
  5. Keep the animation short and write a separate rule for the reduced motion preference.
  6. Test on a real phone, on a slow connection and in a browser without support.
  7. Compare your Core Web Vitals before and after the change.

Step three looks minor, but its impact is large. When the header and logo stay put, visitors feel they never left the site; only the content area changes.

What do the pageswap and pagereveal events do?

In cross-document transitions, you sometimes want to decide which element gets a name based on the direction of navigation. The Chrome guide defines two events for that: pageswap fires on the old page right before its last frame renders, and pagereveal fires on the new page before its first rendering opportunity. Both give access to the transition object, so you can skip the transition or assign names dynamically.

The same guide sets an important technical condition: you must register the pagereveal listener in a classic, parser-blocking script in the head, or in an async script marked as render blocking. Otherwise the event passes before you start listening.

Transition types come in here as well. According to the guide, you can declare types inside the @view-transition rule or add them during the events; in CSS, you respond with :active-view-transition-type() to write different animations per type. For example, you build a transition that slides right on forward navigation and left on back navigation. Types do not carry over between pages automatically, and the browser clears them when the transition ends.

Where should you use same-document transitions in a single page app?

Same-document transitions help anywhere content changes without a page load. Common examples include tabs, product filters, gallery views and switching between list and grid layouts. In these cases, an instant swap makes visitors lose track of what moved. A short transition makes the change visible.

For example, imagine sorting a product list by price. If each product card has a unique name, the cards glide into their new positions, and visitors can follow which product moved up. However, animating hundreds of cards at once can stutter on low-powered phones, so consider naming only the cards currently on screen.

Also, tie transitions to user actions. In content that refreshes on its own, such as an announcement strip that rotates every few seconds, constant transitions distract. A transition makes sense when it responds to the visitor's own click.

How do you choose transition duration and easing?

The official documentation does not prescribe a duration; you decide it. Our field experience suggests that short durations land better for page transitions, since visitors do not want to wait for an animation on every click. That is a starting point to validate by testing, not a rule.

Easing matters as much as duration. A curve that starts fast and slows at the end makes the element feel as if it settles into place gently. A linear curve, by contrast, often feels mechanical. In addition, keeping the exit animation slightly shorter than the entry gives the new content focus sooner.

  • Page transitions: a short duration with a soft ease-out curve.
  • Card to detail matches: a slightly longer but still restrained duration.
  • Reduced motion preference: only a short fade.

For the final decision, test with real users on real devices. A duration that feels fluid on desktop can feel heavy on a phone.

How do images and fonts affect the transition?

In cross-document transitions, the animation starts once the first frame of the new page is ready. If the large image has not loaded yet at that moment, the transition flows into an empty area and the image pops in later. The Chrome guide notes specifically that render blocking with <link rel="expect"> waits only for a given element to enter the DOM; it does not wait for images to load.

So you keep the images that take part in the transition light. Optimizing the size of the large detail image, using the right format and loading the key image with priority all make the transition cleaner. Likewise, a late font can make text jump at the end of the transition, so you adjust your font loading strategy accordingly.

Put simply, a transition exposes your page's loading quality as it is. On a page that loads fast and cleanly, the transition looks elegant; on a page that loads messily, it makes the problems more obvious.

Which browsers support the View Transitions API?

Browser support changes quickly, so instead of listing version numbers here, we explain how to check. Look up the current status in the MDN compatibility tables and in the support boxes of the Chrome guides.

The general picture looks like this: same-document transitions have reached wider support than cross-document transitions. Cross-document support is narrower; when we reviewed the Chrome guide, it listed Chromium-based browsers and Safari, while Firefox did not appear. That can change, so check for yourself before deciding.

The key point is that an unsupported browser breaks nothing. With same-document transitions and feature detection, the update still happens; with cross-document transitions, the browser ignores the CSS rule and performs a normal page load. That is why you can use the View Transitions API safely today and give supporting browsers a smoother experience.

How do you respect the reduced motion preference?

For some people, motion on screen causes real discomfort. The MDN prefers-reduced-motion reference states that animations such as scaling or panning large objects can trigger vestibular motion disorders. Users express this preference through their operating system's reduce motion setting.

Therefore you wrap your transitions in a @media (prefers-reduced-motion: reduce) query. The Chrome same-document guide draws a subtle distinction here: reduced motion does not mean no motion. Replacing slides and scaling with a short fade keeps the relationship between elements while reducing discomfort.

  • In the default experience, you can use sliding or growing transitions.
  • Under the reduced motion preference, turn them into a short fade.
  • Keep the duration short in both cases.

For broader accessibility principles, see our guide on web accessibility and WCAG standards. Keyboard focus should also survive the transition; we covered that in keyboard navigation and focus order.

Does the View Transitions API affect performance and Core Web Vitals?

Set up correctly, the transition itself is light, because the browser runs the animation in its own layers. However, a transition does not make a slow page feel fast. The Chrome guide says plainly that fast-loading pages get the best results.

The guide adds two concrete warnings. First, render blocking with <link rel="expect" blocking="render"> delays the first paint until a given element enters the DOM; the guide recommends using it sparingly and measuring the effect on Core Web Vitals. Second, in Chrome, if a navigation takes longer than four seconds, the browser skips the transition and throws a timeout error.

So you get page speed in order before adding transitions. For the overall framework, see what Core Web Vitals are, and for interaction delay, how to improve INP. If elements move during the transition, our guide to cumulative layout shift helps you tell intentional motion from layout shift.

How do you combine Speculation Rules with the View Transitions API?

The Chrome cross-document guide recommends prerendering with the Speculation Rules API for fast page loads. The logic is simple: if the target page gets ready in the background before the visitor clicks, the new page arrives almost instantly and the animation plays without interruption.

That pairing gives a classic multi page site the feel of a single page app. Moreover, you get there without changing your site's structure, keeping the plain HTML pages that search engines like. Our sibling guide on Speculation Rules and prerendering explains how to write the rules, which pages to exclude and what the risks are.

That said, overly broad prerendering raises server load and data use. So when you set up both, you define a performance budget; we explained the concept in what a performance budget is.

What should you watch when adding the View Transitions API to an existing theme?

On sites built with a ready-made theme or page builder, the first issue is access to the shared stylesheet. Adding the rule to the theme's custom CSS field is usually enough; however, if the theme loads a different stylesheet on some pages, those pages will not join the transition. So after adding the rule, you click between the home page, blog, contact and product pages one by one.

The second issue is the theme's own animations. Theme effects that slide content in on page load can overlap with the browser's transition and create a messy result. In that case you pick one. Keeping the browser transition and turning off the theme's entrance effect usually gives the cleaner result.

Third, watch fixed elements. If a sticky header, cookie bar or chat bubble sits in the same place on every page, giving it a fixed name prevents flicker during the transition. Then visitors see only the content change. Finally, try everything on a staging site first, not on the live site.

How do you debug a transition that does not behave?

If the transition never plays or behaves oddly, work through it in order rather than making random changes. First confirm both pages include the rule, then confirm both pages share an origin. Next, check the browser console for errors; duplicate names and timeouts usually leave a trace there.

If the animation runs too fast to see what happens, temporarily lengthen the duration and watch it in slow motion. To see which element lands in which group, inspect the pseudo-element tree that appears during the transition in your developer tools. After you find the problem, restore the original duration and run a quick check in an unsupported browser as well.

What does a realistic example scenario with the View Transitions API look like?

Example scenario: an architecture firm's website has a project list and project detail pages. The firm dislikes the hard page reload when visitors click a project; it wants a smoother transition that feels like a gallery.

The setup goes like this. First, the developer adds the cross-document rule to the shared stylesheet in one line, and the default fade starts on every page. Next, the developer gives the header and logo fixed names, so they stay in place during the transition. Then the clicked project's cover image on the list page and the large image on the detail page get the same name, and the image glides from the small card to the large header.

In the last step, the developer defines a short fade for the reduced motion preference, confirms the site works normally in an unsupported browser and compares speed metrics. This is not a client case; it is a simplified version of a setup we often recommend.

What are the most common mistakes?

The View Transitions API looks easy, but a few traps quietly break transitions:

  • Giving every card on a list page the same view-transition-name value, so the browser skips the transition.
  • Adding the rule to only one page, although both pages must opt in.
  • Expecting transitions across origins, such as between www and non-www versions.
  • Using long, showy animations that make visitors wait on every click.
  • Ignoring the reduced motion preference.
  • Trying to hide a slow page behind a transition; the guide says long navigations skip it anyway.
  • Using render blocking on every page without measuring it.

All these mistakes share one root: treating the transition as the goal. A transition is a small detail that serves content and navigation, and it earns its place when you use it with restraint.

Do page transition animations suit every site?

No, not at the same intensity. On portfolio, product catalog and gallery-heavy sites, transitions genuinely help visitors keep context. By contrast, the steps of an application form or a fast checkout flow need speed, not showy motion.

A practical test: a transition earns its place when it answers the visitor's question "where did I come from and where am I now". If it exists only for decoration, a short fade is enough. We covered where small interaction animations help in micro-animations in web design, and how much brand motion makes sense in logo animation for the web.

Also consider fit with your brand identity. A calm, trustworthy law firm site and an energetic event site should not share the same transition language; duration and easing carry the brand's tone.

When can you set it up yourself, and when do you need help?

If you have a shared stylesheet and want only the default fade, adding and testing the cross-document rule is usually something you can do yourself. Since it does no harm in unsupported browsers, the risk of trying is low.

However, once card to detail matching, direction-aware transitions, event listeners and speed optimization enter the picture, the work requires design and code thinking together. If a ready-made theme cannot manage these names and events cleanly, the transition either runs inconsistently or hurts speed metrics. At that point, a team that sees design, code and performance together saves both time and quality.

How do we help with this?

When we take on corporate website design, we handle brand-specific design, speed and Core Web Vitals at the same table. We build sites with lean custom code instead of bloated themes and plugin stacks, with optimized images and proper caching. We add details such as page transitions in a way that respects that speed target and matches the brand's tone.

If you want to add page transitions to your current site, you can start yourself with the step-by-step list above. If you are planning a new site, or want transitions, speed and accessibility planned together from the start, we confirm scope in writing after your quote request.

Frequently Asked Questions

Do I need JavaScript for the View Transitions API?
For cross-document transitions, usually not. A single CSS rule on both pages starts the default cross-fade. Same-document changes need a small JavaScript call, and advanced setups such as direction-aware transitions or dynamic naming also need some JavaScript. Even so, the basic setup stays very short and easy to maintain.
Will my site break in browsers without support?
No. In cross-document transitions, the browser ignores the CSS rule and performs a normal page load. In same-document transitions, feature detection lets the update happen without animation. That is why the View Transitions API works well as progressive enhancement, and functionality never depends on the animation itself.
Why does the transition not run on some pages?
The usual reasons are threefold: only one page includes the rule, the two pages sit on different origins, or more than one visible element uses the same transition name. In Chrome, very slow navigations also skip the transition. Checking these four points in order solves the problem in most cases.
Do page transitions affect SEO?
There is no direct ranking effect, since the transition changes neither the content nor the address of a page. The indirect effect runs through speed and user experience. A transition does not hide a slow page, and unmeasured render blocking can worsen Core Web Vitals, so you measure first and add transitions afterward.
Should I turn transitions off completely for reduced motion?
Not always. The Chrome guide stresses that reduced motion does not mean no motion. Replacing slides and scaling with a short fade keeps the relationship between elements while reducing discomfort. Still, you should always honor the user's preference through a media query and test the result on a real device.
Should I combine the View Transitions API with Speculation Rules?
If you want a fast, fluid experience, combining them makes sense. The Chrome guide notes that cross-document transitions look best on fast-loading pages and that prerendering helps with that. However, keep your prerender rules narrow, watch server load and keep an eye on data use for mobile visitors.
  • view transitions api
  • page transitions
  • css animation
  • web performance
  • accessibility
  • speculation rules
  • web design
Share:
Talha Aslan

Google Partner digital marketing expert. Hands-on with SEO, Google Ads, web design and e-commerce projects since 2012; every post here comes from that experience.

Next project

Get a quote for your project.

Your brief goes straight to Talha Aslan and team: strategy led by Talha, delivery by an experienced team. We reply the same day and send the scope, timeline and price as a written quote within 1 business day.