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
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.
Copy / paste basic React example from the docs with useAuth or useUser context
Cannot find context on page load
Expected behavior:
No errors and being able to retrieve the auth / user context
Actual behavior:
Error: UserContext not found
at assertContextExists
I only briefly looked into the issue. This used to be a HMR issue on Vite for a while that Context wouldn't work, but it's been fixed roughly a year ago. I assume this has to do with the fact that there are some custom wrappers for Context Creation. I tried a normal CreateContext / useContext example in the same app and it works without issues.
PS: I'm not confirming it's a HMR issue. I just stumbled upon this issue vitejs/vite#3301 which appears to be very similar, and I assume since useAuth / useUser are React context, it must be related.
Hey @AndreasGalster2 - we looked into this and noticed that you are calling useUser outside the context of the <ClerkProvider> component. In order for useUser to render correctly, it needs to be called inside a component that is wrapped with <ClerkProvider>.
We certainly could do a better job with this error message, and are adding a task for this in our internal backlog, but this should be able to be resolved in your app by adjusting the scope of <ClerkProvider> right away 😁
Preliminary Checks
I have reviewed the documentation: https://clerk.com/docs
I have searched for existing issues: https://github.com/clerk/javascript/issues
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.
Reproduction / Replay Link
https://stackblitz.com/edit/vitejs-vite-jnusqg?file=src%2FApp.tsx,package.json&terminal=dev
Publishable key
pk_test_Y2xldmVyLXNxdWlycmVsLTU5LmNsZXJrLmFjY291bnRzLmRldiQ
Description
Steps to reproduce:
https://stackblitz.com/edit/vitejs-vite-jnusqg?file=src%2FApp.tsx,package.json&terminal=dev
Expected behavior:
No errors and being able to retrieve the auth / user context
Actual behavior:
I only briefly looked into the issue. This used to be a HMR issue on Vite for a while that Context wouldn't work, but it's been fixed roughly a year ago. I assume this has to do with the fact that there are some custom wrappers for Context Creation. I tried a normal CreateContext / useContext example in the same app and it works without issues.
PS: I'm not confirming it's a HMR issue. I just stumbled upon this issue vitejs/vite#3301 which appears to be very similar, and I assume since useAuth / useUser are React context, it must be related.
Environment
The text was updated successfully, but these errors were encountered: