Gal Malachi
10/24/2025, 10:50 AMRahul Rijhwani
10/24/2025, 11:05 AMuseUser 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:
'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-storageGal Malachi
10/24/2025, 11:06 AM