-
Notifications
You must be signed in to change notification settings - Fork 291
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
feat(astro): Add support for View Transitions #4354
Conversation
🦋 Changeset detectedLatest commit: b58e76b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const emotionElements = document.querySelectorAll(`style[${EMOTION_ATTR}]`); | ||
swapHeadElements(doc, Array.from(emotionElements)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems great. In the video, i see that the "afterSignIn" navigation did not run with the page transitions (fade-in/out). Is this expected ?
@@ -0,0 +1,61 @@ | |||
// eslint-disable-next-line import/no-unresolved | |||
import { swapFunctions } from 'astro:transitions/client'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Is this always bundled with Astro ? Is there a case where the module will not exists causing our integration to break ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed bundled with Astro (astro/virtual-modules/transitions-swap-functions.js
), but is not available in Astro v3.
Also we let the Astro Vite plugin handle it by excluding from vite.optimizeDeps
:
config.optimizeDeps?.exclude?.push('astro:transitions/client'); |
Good catch! I've added another update that will use the Screen.Recording.2024-10-18.at.7.59.28.AM.movIt should now handle any routing within the components too |
!snapshot |
Hey @wobsoriano - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
Hey @wobsoriano! I'm using @clerk/astro v1.4.7, which should contain this change. However, I'm still seeing exactly this behavior on Cloudflare Pages with the UserButton disappearing randomly on navigation:
My workaround is to use UserButton from Maybe they changed something in the latest Astro release?
|
@wobsoriano It looks like the UserButton disappears when navigating between pre-rendered and server-rendered pages. One page in my app uses React without SSR. Adding |
Description
This PR adds Astro View Transitions support to our Clerk components. It is basically the "SPA mode" for Astro.
Before this change, Clerk components didn't work properly with Astro View Transitions. When using the
<ViewTransitions />
component in an Astro app, our Clerk components weren't remounting during page navigation.The solution was to:
runInjectionScript
function in theastro:page-load
to ensure Clerk components are properly mounted when switching pages.@emotion/cache
. This maintains the styling across page transitions.Here's a basic demo using
<SignIn />
,<UserProfile />
and<UserButton />
components being rendered in a view transitions enabled pages:Screen.Recording.2024-10-17.at.1.10.21.PM.mov
Resolves ECO-64
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change