K
Kinde

💻┃support

Can't get the user info from const { getUser } = getKindeServerSession();

JJacob2/6/2024
I must be totally braindead but I'm just trying to get the information about the user in this way. Using next.js. import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
```
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

const Page = () => {
const { getUser } = getKindeServerSession();
const user = getUser();

return (
<MpWrapper className="mt-32">
<h1>Dashboard</h1>
<p>User: {user.email}</p>
</MpWrapper>
);
};
```
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

const Page = () => {
const { getUser } = getKindeServerSession();
const user = getUser();

return (
<MpWrapper className="mt-32">
<h1>Dashboard</h1>
<p>User: {user.email}</p>
</MpWrapper>
);
};
Property 'email' does not exist on type 'Promise<KindeUser | null>'. Isn't it supposed to be an object? I'm logged in and everthing. I'm every writing exactly as Josh tried coding does
MMALEV0L3NT2/6/2024
Hey, I answered in #💬┃general but I'll answer here too. You need to make your Page function an async function and to await your getUser call:
const Page = async () => {
...
const user = await getUser();
...
}
const Page = async () => {
...
const user = await getUser();
...
}
JJacob2/6/2024
thank you so much sir, of course. How could I have missed this. I spent 3 hours on this. HGHAHAHHA
MMALEV0L3NT2/6/2024
getUser is an asynchronous function which means in order to use the value it returns (KindeUser | null), we need to wait for the execution to finish. There's multiple ways we can do this, but the best is probably to await it No worries 🙂
JJacob2/6/2024
oh so before the data was actually there it was just a promise
MMALEV0L3NT2/6/2024
Yes exactly. The Promise object represents the eventual completion of a task
JJacob2/6/2024
Its strange it worked for Josh tried coding in his popular video "Build a Complete SaaS Platform with Next.js 13, React, Prisma, tRPC, Tailwind | Full Course 2023". He didnt have async.
MMALEV0L3NT2/6/2024
When we run what you had: const user = getUser(); JavaScript calls the getUser() function and then immediately continues. This returns a Promise as we can't guarantee the getUser function is finished, being an asynchronous task. When we write the await keyword, we're telling JavaScript to wait at that point until the getUser() function is finished
JJacob2/6/2024
I learn new things every day. Thanks.
MMALEV0L3NT2/6/2024
MDN Web Docs
Promise - JavaScript | MDN
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
MDN Web Docs
await - JavaScript | MDN
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module.
MMALEV0L3NT2/6/2024
Here's some further reading if you're interested, they're important concepts, especially now with RSC
JJacob2/6/2024
Yeah I know in theory what asyncronious js is. What is RSC? Thanks btw for the extended explanations. Really appreciated.
MMALEV0L3NT2/6/2024
React Server Components (next.js app router)
JJacob2/6/2024
oh yes! ok! I've said for 5 years I'm not going to become a decent developer its just something life put me to do 😄 but still I learn more everyday. haha. It's actually very fun once you start grasping the concepts a bit better. And kinde is very good for me, because all hackers from Russia are trying to break all Swedish systems now I dont have to worry about the auth security lol
MMALEV0L3NT2/6/2024
I agree 🙂 Btw I see the josh tried coding video you're talking about, curious that he's not using async and it's working for him... Maybe one of the Kinde guys can answer that for us
JJacob2/6/2024
Next time something like this happens I have more wisdom. I agree pretty strange indeed.
Ppeteswah2/7/2024
Ah yep, in the Joshtriedcoding video it may have been a previous version of the sdk 🙂
DDaniel_Kinde2/7/2024
Yes, the API was updated to be async I believe after JostTriedCoding video.
MMALEV0L3NT2/7/2024
There we go, that makes sense. Thanks for the clarification 🙂

Looking for more? Join the community!

K
Kinde

💻┃support

Join Server
Want results from more Discord servers?
Add your server
Recommended Posts
Using custom login pageHi, I am trying to use a custom login page. I have my page implemented with a login button and on clGet Users with Kind TS-SDKI have just started out with the Typescript Sdk with Nestjs and the Kinde Api to get Users and I havKINDE_AUTH_WITH_PKCE on sveltekit throws errorHi, When trying to authenticate you'll get redirected to the callback url. When the request hits the!https://discord.com/channels/1070212618549219328/1202723739444445245/1202858352938582046Malformed Response CookieHello, we've been getting a malformed cookie response when certain roles are added a user with multiAuth check in +layout.server.ts – known issues?Hi! 🙌 From working in SvelteKit I've gotten used to avoiding +layout.server.ts for auth checks (rAdd audience using Nuxt ModuleI looks like this may not be implemented, but I could very well have messed something up at my end. Dark Mode & Multiple Organization LoginHi! It seems when using Dark Mode & a user has multiple organizations to select from, we cannot custPersistent Auth & Custom Domainshi! I am trying to understand whether Custom Domains are truly the only way to have persistent auth?custom auth pagesThe is a post made after @Daniel_Kinde asked. It is about my question on how is the login method impGithub connection doesn't pull name in IDTokenJust wanted to know if this was intention or if I messed up the configuation, but the name claim in The specified organization could not be found.is somebody help me with this 🥲 using kinde for the first time !Limitations of Discord Auth IntegrationHey :) I am working on a bot dashboard currently and was trying out kinde as a possible auth provideWildcards in callback URLs bugI'm trying to use https://kinde.com/docs/connect-to-kinde/callback-urls/#wildcards-in-callback-urls custom sign in in node.jsHow do i send the custom authurlparm to my node.js signin? authUrlParams: { connection_Offline Usage of Kinde AuthHello, I will have a web app (react or nextjs) and a mobile app (ios and maybe later android). All Is there a way for the login/signup happen in a modal rather than a full redirect?Hello, I've got Kinde up and running on a side project, I was wondering if instead of redirecting I Import error with Kinde TypeScript SDK in Next.js 14 project using PNPMHello everyone, I've recently integrated the Kinde auth solution into my Next.js 14 project, utilizProblem with the SvelteKit SDK.Hi! I tried to integrate Kinde with my exiting Sveltekit 2 project, I have followed the official docHaving problems with logout URLsI have them configured in my settings, but I'm still getting sent to the Kinde logout page. Screensh