Welcome to the Kinde community

Updated 6 months ago

orgCode attribute in nextjs

Plain Text
console.log("organization", organization.orgCode);
This is still wrong in nextjs. orgCode always returns undefined

I'm using "@kinde-oss/kinde-auth-nextjs": "^2.2.3",
1
D
I
p
10 comments
Hi, can you provide an extended code example for me to investigate?
Plain Text
const { user, organization } = useKindeBrowserClient();
  console.log("organization", organization.orgCode);
This will cause the error and it's because organization from useKindeBrowserClient is of type KindeOrganization or it should be a string. I think it's the second time I report this
Hey @IkiTg07 which version of the SDK are you experiencing this issue on?
The above code works for me in the latest version, 2.2.13
So long as I use it after "isLoading", otherwise I have to do
Plain Text
console.log("organization", organization?.orgCode);
with question mark because organization is undefined when still loading
I’m on version ^2.2.3
We would recommend that you upgrade to SDK v2.2.13 as there is lot of other fixes that have been rolled. Is that possible for you?
Well it seems to work but when typing
Plain Text
organization.orgCode
it causes an error
Plain Text
TypeError: Cannot read properties of null (reading 'orgCode')
. I have to add '?' after organization soo
Plain Text
organization?.orgCode
. The type of organization is KindeOrganization. You should change it to KindeOrganization | null
Mmm thanks for flagging I have passed along to the team who manages the NextJS SDK
Add a reply
Sign up and join the conversation on Discord