Server Utilities
currentUser
The currentUser helper is the secure way to access the authenticated user's profile within Server Components, Server Actions, and API Routes.
Usage
Pass the request object to retrieve the current session data:
terminal
import { currentUser } from "@ezz-auth/next";
export default async function ProfilePage(request) {
const user = await currentUser(request);
if (!user) {
return <div>Not signed in</div>;
}
return <div>Hello, {user.name}</div>;
}Security & Behavior
Server-Side Validation
Every call performs a direct validation against the Core Auth System to ensure the session is still active.
Spoof Protection
Identity is verified via secure HTTP-only cookies, making it impossible for clients to manipulate user data.
Null Safety
Returns null for unauthenticated requests, allowing for easy conditional rendering on the server.