GithubHelp home page GithubHelp logo

Comments (5)

panteliselef avatar panteliselef commented on May 24, 2024 2

Hey @kyldvs, those are 2 different types and should not be treated as a "common" interface.

firstName exists for both types. You are correct primaryEmailAddress only exists for the client one, as a workaround you can depend on primaryEmailAddressId and the emailAddresses array which both exist in both types.

F.e.

primaryEmailAddress = emailAddresses.find(({ id }) => id === primaryEmailAddressId)

from javascript.

Jhinger avatar Jhinger commented on May 24, 2024 2

Also experienced this issue while trying to get a users' organizationMemberships from currentUser - the User type returned from currentUser and useUser are not the same and the docs should be updated to reflect that (or ideally as @kyldvs mentioned the interfaces should be updated to match).

https://clerk.com/docs/references/nextjs/current-user

from javascript.

ubersan avatar ubersan commented on May 24, 2024 1

It would be indeed nice to know if it's planned to also provide the additional properties (e.g. orgs) in the server-side variant currentUser.

from javascript.

kyldvs avatar kyldvs commented on May 24, 2024

Thanks for the fast response! I guess at a minimum this is an error in the documentation, but I am hoping this can be updated to be the same interface for both.

Right now it's annoying to share some utilities working with Clerk users across server & client because of the different types (in a graphql context, not SSR, otherwise I could just use the same hooks). Is that possible or is it intentional that these types are different?


The error in the documentation would be that the currentUser() page claims to return a User object, and that user page claims to have properties like fullName and primaryEmailAddress (also to avoid potential confusion you mention firstName, but I have been talking about only fullName in this issue). But the currentUser() function does not return an object with those properties.

from javascript.

thinkjrs avatar thinkjrs commented on May 24, 2024

I also ran into this today and would love to see the interfaces match if possible! @panteliselef 🙏 Thanks for the solution, this works fine for now!

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.