You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
<SignIn> Component Not Rendering After Signing Out When Component Has Appearance Props Added #1981
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Expected behavior:
After clicking the the user should be redirected to the sign in page with a component displaying that has appearance props.
Actual behavior:
After clicking the the user is redirected to the sign in page but the component does not render when it has the appearance prop set. If the appearance prop is set the component displays properly.
I have an issue that sounds very similar, but with the <UserButton />. After signing out, and signing back in, it renders at size 0x0.
Not sure if it's related or not, but the browser console is showing a couple of errors related to signin. The stack trace is to a packed vendors file, so the line numbers probably aren't relevant, but the error is "Uncaught TypeError: Cannot read properties of undefined (reading 'imageUrl')" and the line of code sets avatarUrl with l.userData.imageUrl, where l is a minified variable name.
All that to say that it looks like it is somehow trying to set the avatar with the imageUrl of a userData that hasn't been initialized yet.
Just a short update here to show that I/we haven't forgotten this issue 😅 Thanks for the reproduction, I was able to also see the issue. Important bit: This also happens without the appearance prop.
After investigating I'm still not sure exactly what is causing it, might be a race condition or an issue with client side re-hydration.
We'll discuss internally a bit how we want to tackle this but I'd be interested in your opinion on this question (@brettabamonte@tjl-jg@IGassmann):
What is your expected behavior for the <SignOutButton /> as to where it should navigate?
Should it stay on the same page? Navigate to the sign in page? Navigate to a custom page one has to define?
My opinion about redirect options: I prefer full context to be in my code, so I'd probably use a property specifying the redirect destination even if my destination was the default. This way it shows up in searches of the project, and the action is clear later on (or to other developers) without anybody having to read documentation.
@LekoArts I agree with @tjl-jg. I like the context to be within the component using a property. Having a default destination is nice if the property isn't declared on the component. 90% of the time, I like redirecting users to a default page like the sign in page but there are instances where it'd be nice to redirect them to a custom destination.
@LekoArts I agree with @tjl-jg. I like the context to be within the component using a property. Having a default destination is nice if the property isn't declared on the component. 90% of the time, I like redirecting users to a default page like the sign in page but there are instances where it'd be nice to redirect them to a custom destination.
Thank you and the team for looking into this!
I agree. Additionally, there may be situations where redirection is not desired. Consider an app that functions both when signed in and when signed out, where being signed in is not essential for using the app.
@brettabamonte What your reproduction shows is in some sense "expected" behavior that is described in this thread here. The blank page shows because it shows the unauthenticated state of the /dashboard route which will be empty. The behavior you want kicks in because the middleware redirects to the sign-in page because /dashboard is not a public route.
With the callback prop above you can reliably do whatever you want after the signout 👍
We'll still look into the underlying issue and see if we'd need to change something DX-wise.
I have the same problem as @tjl-jg. Here is a minimal reproduction by the way: Sengulair/clerk-nextjs-app-issue@f7a29db
It still appears on the 5.0.1 version. Do we have some workaround for that case?
Activity
tjl-jg commentedon Nov 7, 2023
I have an issue that sounds very similar, but with the
<UserButton />. After signing out, and signing back in, it renders at size 0x0.Not sure if it's related or not, but the browser console is showing a couple of errors related to signin. The stack trace is to a packed vendors file, so the line numbers probably aren't relevant, but the error is "Uncaught TypeError: Cannot read properties of undefined (reading 'imageUrl')" and the line of code sets avatarUrl with l.userData.imageUrl, where l is a minified variable name.
All that to say that it looks like it is somehow trying to set the avatar with the imageUrl of a userData that hasn't been initialized yet.
IGassmann commentedon Nov 15, 2023
I can confirm this also happens on
@clerk/nextjs: 4.27.1/next: 14.0.2. However, it happens for us independently of the use of theappearancepropLekoArts commentedon Dec 6, 2023
Hello all!
Just a short update here to show that I/we haven't forgotten this issue 😅 Thanks for the reproduction, I was able to also see the issue. Important bit: This also happens without the appearance prop.
After investigating I'm still not sure exactly what is causing it, might be a race condition or an issue with client side re-hydration.
We'll discuss internally a bit how we want to tackle this but I'd be interested in your opinion on this question (@brettabamonte @tjl-jg @IGassmann):
What is your expected behavior for the
<SignOutButton />as to where it should navigate?Should it stay on the same page? Navigate to the sign in page? Navigate to a custom page one has to define?
tjl-jg commentedon Dec 6, 2023
My opinion about redirect options: I prefer full context to be in my code, so I'd probably use a property specifying the redirect destination even if my destination was the default. This way it shows up in searches of the project, and the action is clear later on (or to other developers) without anybody having to read documentation.
brettabamonte commentedon Dec 7, 2023
@LekoArts I agree with @tjl-jg. I like the context to be within the component using a property. Having a default destination is nice if the property isn't declared on the component. 90% of the time, I like redirecting users to a default page like the sign in page but there are instances where it'd be nice to redirect them to a custom destination.
Thank you and the team for looking into this!
IGassmann commentedon Dec 7, 2023
I agree. Additionally, there may be situations where redirection is not desired. Consider an app that functions both when signed in and when signed out, where being signed in is not essential for using the app.
LekoArts commentedon Dec 8, 2023
Thanks for your input!
Then you can unblock yourself by using the
signOutCallbackprop on the<SignOutButton />component:Or if you want to reload the page (you'd want to make that page public then though):
@brettabamonte What your reproduction shows is in some sense "expected" behavior that is described in this thread here. The blank page shows because it shows the unauthenticated state of the
/dashboardroute which will be empty. The behavior you want kicks in because the middleware redirects to the sign-in page because/dashboardis not a public route.With the callback prop above you can reliably do whatever you want after the signout 👍
We'll still look into the underlying issue and see if we'd need to change something DX-wise.
Sengulair commentedon Apr 24, 2024
I have the same problem as @tjl-jg. Here is a minimal reproduction by the way: Sengulair/clerk-nextjs-app-issue@f7a29db
It still appears on the 5.0.1 version. Do we have some workaround for that case?
panteliselef commentedon May 1, 2024
@Sengulair mind giving this another try with 5.0.4
Sengulair commentedon May 1, 2024
@panteliselef I've updated the reproduction to 5.0.4. Still failing with the same errors
Sengulair commentedon May 3, 2024
@panteliselef Tested with 5.0.6 and seems the problem is resolved.
dimkl commentedon May 9, 2024
Closing this as it seems resolved. @brettabamonte If the issue persists after using a version >= 5.0.6, feel free to re-open the issue.
clerk-cookie commentedon May 10, 2025
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.