Hi @bazar21 ,
Thank you for your question. To determine if a user is authenticated without making multiple asynchronous calls, you can streamline your code as follows:
const { isAuthenticated, getUser } = getKindeServerSession();
if (await isAuthenticated()) {
const user = await getUser();
// Proceed with authenticated user logic
} else {
// Handle unauthenticated user scenario
}
This approach ensures that you only call getUser() when the user is authenticated, reducing unnecessary asynchronous operations.
For more details, you can refer to the Kinde TypeScript SDK documentation:
https://docs.kinde.com/developer-tools/sdks/backend/typescript-sdkIf you have further questions or need additional assistance, feel free to ask