clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.11k stars 245 forks source link

useUser(), <SignInButton> component, and useClerk() are inconsistent #1673

Closed leo-paz closed 10 months ago

leo-paz commented 1 year ago

Brief Summary of the Issue

useUser().isSignedIn returns false yet useClerk().user has the correct user details. I also have had so much trouble using and i'm assuming this is related. I get a next hydration error every time I try to use the built in component.

Minimal Reproduction or Replay

image

image

Browser/OS

_If applicable e.g. Chromium 115.0.5790.114, Node 18.10.0

Package + Version

panteliselef commented 1 year ago

Hello @leo-paz Could u provide us with a repo or something like a CodeSandbox ? The above code seems to work as expected when I moved it to an existing project.

Also about issue with <SignInButton/> what seems to be the problem ?

leo-paz commented 1 year ago

@panteliselef Thanks for the prompt reply. So I tried branching off the clerk-next-app-router-starter project after I tried copying over how the built in components were used in layout.tsx I get this error locally:

Error: Clerk: auth() was called but it looks like you aren't using `authMiddleware` in your middleware file. 
Please use `authMiddleware` and make sure your middleware matcher is configured correctly and it matches this route or page. 
See https://clerk.com/docs/quickstarts/get-started-with-nextjs

my middleware.ts is at the same level as /app and I only see it after trying to use these components in the layout.tsx.

I'm not sure what I'm doing wrong :/ heres a code snippet image image

leo-paz commented 1 year ago

@panteliselef i found a related thread and have attached a link in this comment that reproduces the issue: https://github.com/clerkinc/clerk-next-app-router-starter/issues/2#issuecomment-1703550642

kayog123 commented 1 year ago

I have the same issue. The useUser hook is inconsistent.

clerk-cookie commented 1 year ago

Hello πŸ‘‹

We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! πŸ™

tolgaouz commented 12 months ago

I also had this problem with my next 13 setup. This issue saved us from migrating off of Clerk. Thank you @leo-paz

clerk-cookie commented 11 months ago

Hello πŸ‘‹

We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! πŸ™

jescalan commented 10 months ago

Inactive for 40+ days, reproduction not provided, closing this one. Please feel free to open a new issue if anyone else runs into similar issues!