Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

currentUser()

The currentUser helper returns the Backend API User(opens in a new tab) object of the currently active user. It can be used in Server Components, Route Handlers, and Server Actions.

Under the hood, this helper:

  • calls fetch(), so it is automatically deduped per request.
  • uses the GET /v1/users/me endpoint, so it is subject to rate limits.
app/page.tsx
import { currentUser } from '@clerk/nextjs/server'; export default async function Page() { const user = await currentUser(); if (!user) return <div>Not signed in</div>; return <div>Hello {user?.firstName}</div>; }

Last updated on April 3, 2024

What did you think of this content?

Clerk © 2024