-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add some hint with pros and cons why the <ClientRouter /> is not the only approach to view transitions. #10902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If it is not in the docs, it can't be true ;-) The ClientRouter and the View Transition API have different scopes. Some ClientRouter functionality is about turning a MPA into a SPA (transition:persist, cross-page state, script re-execution, route-announcer), others are extensions of the View Transition / Navigation API (forward/backward directions, predefined (fade/slide) and custom animation functions, reduced motion check, automatic cross-document names, sourceElement, popstate events), others are just different (programmatic navigation, lifecycle events) To me, untangling these feature does not seem worth it. So I would leave the ClientRouter as is but add some explanation at the start of the current view transition docs:
(One can certainly wish for extensions to view transitions (things like directional animations, state transfer, or ready-made animations) but those can come from third-party libraries. They do not need to be part of the Astro core). |
Thank you Martin for this great and detailed analysis to get this started! I will firstly say, just to frame any further work (and make public for the sake of others who may be newly getting involved with how Astro docs works), that the ultimate purpose of Astro Docs is to document how Astro works: it's not our mandate to document "how to do view transitions" as a broad browser concept (e.g. https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API/Using#basic_mpa_view_transition), and instead our primary focus is documenting "Astro features that we built and how they work" (e.g. A page intro could start with basic content (e.g. along the lines of this content from Mozilla), much like our other "general concept done in Astro" pages, like Markdown for example, where we define what the thing is, then say how it is used in Astro:
From here, Martin's points follow nicely, allowing us to move into what Astro provides and what it is for, focusing on using it for cases where support is lacking:
So, I'm thinking something like that to frame this page? (Obviously you will help make sure that it's accurate and the right nuance of everything!) This also feels fairly "future-proof" in that it nudges to consider the development of web standards, even while we still maintain comprehensive documentation of everything we provide. |
Thanks a lot, @sarah11918! The way you tell stories feels so effortless. It’s honestly beyond me how you manage that. From my perspective, this is a nearly finished, perfect starting point for a PR. It really supports my intention to help people better understand what they are getting into. We can adjust the small details in the PR. |
(You're too kind, Martin!) So I would say, it sounds like we have an idea for a reframing for the intro of this page! I'm happy if you'd like to make a PR to update the intro to the View Transitions guide and we can work out all the details in the PR. (Part of me wonders whether this page should really be (end up being?) "Client-side routing" ... but I don't think we can handle that much right now! 😂 I'm cool taking baby steps here...) Please make a PR at your leisure with whatever you would intro the page with, and we'll all pick this discussion up there! 🙌 |
📚 Subject area/topic
View Transitions
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/de/guides/view-transitions/
📋 Description of content that is out-of-date or incorrect
Right now, view transitions are prominently featured at the end of the 'Routing and Navigation' section in the docs. The page gives the impression that, even in 2025, the recommended way to enable view transitions in an Astro project is by adding the Astro-specific
<ClientRouter />
component.This issue is intended as a nudge to follow through on Fred's announcement from last year. The
<ClientRouter />
fka<ViewTransitions />
was originally meant to allow Astro users early experiments with the then new View Transition API and bridge the time until more browsers offer cross-document view transitions. We shouldn't present the<ClientRouter />
as a routing must-have. Instead, we should clarify upfront that it's a deprecated approach that doesn't align with Astro's "no JavaScript by default" philosophy. And that browser-native cross-document view transitions are the better alternative (if we agree on that).I'm happy to leave the wording in docs to whoever is more involved with the docs.
From my perspective, these points might be helpful for Astro users:
Astro provides a built-in component for cross-document view transitions, even for browsers that only support same-document transitions. (Note: Currently, all browsers either support both or neither.)
It even enables a subset of view transitions for browsers with no native support at all. (Note: Right now, all major browsers except Firefox fully support native view transitions.)
No need for FOMO: Despite the fancy name, the ClientRouter isn’t unlocking a groundbreaking new world of client-side routing.
There are still some things the ClientRouter handles better than native view transitions (Firefox fallbacks, transition:persist, directional transitions, and animation functions). When using native view transitions, you would need extra (third-party) scripts for these.
But learning the still evolving web standard might be a better long-term investment than learning an Astro-specific subset variant.
If your page relies on non-trivial scripts, integrating them with the ClientRouter can be a challenge.
This background information doesn't need to go into the docs. Maybe a brief note at the start of the page is enough to let people know they might be better off using CSS View Transitions instead of the
<ClientRouter />
component.🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response
The text was updated successfully, but these errors were encountered: