Comments (5)
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.
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.
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.
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.
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)
- The German file does not have the correct Typescipt type. HOT 3
- [beta] 'currentUser' is not exported from '@clerk/nextjs' HOT 3
- NextJS protected admin folder "can't detect usage of authMiddleware()" HOT 4
- Double Quote in ENV VAR cause 500 in NextJS production builds HOT 3
- Setting both the 'Origin' and 'Authorization' headers is forbidden HOT 1
- Slim down on dependencies HOT 2
- TS2688: Cannot find type definition file for 'mime' in @clerk/clerk-sdk-node HOT 7
- A Node.js API is used (setImmediate at line: 51) which is not supported in the Edge Runtime. HOT 9
- [beta] Error in Vercel from `Request` global mismatch HOT 1
- Latest @clerk/nextjs package uses deprecated dependency. HOT 1
- Not able to use intellisense for many items that i was able to use few days ago like SignInButton etc HOT 2
- <OrganizationList /> `afterCreateOrganizationUrl` never called HOT 4
- Next.js latest (14.2.0) + Clerk + tRPC + Turbo - fails "createContext only works in Client Components" HOT 13
- Nextjs 14, docker, production error: Failed to load Clerk
- Clerk wrongly redirects to `/factor-one` route HOT 1
- Remix.run Clerk SDK server functions not returning permissions, roles, organization info, etc... HOT 6
- V5: `OrganizationProfile` throws error upon logout HOT 15
- The ignore option for @clerk/upgrade is ignored HOT 5
- React Native Support HOT 1
- Deprecated prop `afterSignInUrl` at `ClerkContextProvider` instead of `fallbackRedirectUrl` or `forceRedirectUrl` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript.