currentUser()
Access the User object inside of your server components, actions and route handlers.
The currentUser
helper returns the current user allowing you to enrich your application. You can use the user object to access the currently active User.
Below is a basic example of usage, however it can be used in, server components, route handlers and server actions.
1import { currentUser } from '@clerk/nextjs';23export default async function Home() {4const user = await currentUser();5if (!user) return <div>Not logged in</div>;6return <div>Hello {user?.firstName}</div>;7}8