sorry if this is dump question, but couldn't spot ...
# ask-a-descoper
g
sorry if this is dump question, but couldn't spot anything clear in the docs/github will useUser work in a nextjs app with session token managed in a secure/http only cookie?
✅ 1
r
Yes,
useUser
will work in a Next.js app with session tokens managed in secure/httpOnly cookies. The
useUser
hook retrieves the currently authenticated user's information and works regardless of how session tokens are stored. When you configure your Next.js app to use httpOnly cookies (by setting up a custom domain and configuring cookie-based session management), the SDK handles token validation automatically. Example:
Copy code
'use client';
import { useDescope, useSession, useUser } from '@descope/nextjs-sdk/client';
 
export default function Dashboard() {
  const { isAuthenticated, isSessionLoading } = useSession();
  const { user } = useUser();
  const sdk = useDescope();
 
  if (isSessionLoading) {
    return pLoading.../p;
  }
 
  if (!isAuthenticated) {
    return pYou are not logged in/p;
  }
 
  return (
    div
      pWelcome, {user?.name}/p
      button onClick={() = sdk.logout()}>Logout/button
    /div
  );
}
Check docs: https://docs.descope.com/getting-started/nextjs/user-and-session-data https://docs.descope.com/client-sdk/auth-helpers https://docs.descope.com/security-best-practices/session-token-storage
g
thanks @Rahul Rijhwani - so what about the dct value? I see that the useUser will not include it, but the useSession will - which I guess won't work in a http only cookie config