Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
Getting Started
Session Management
Get Session

Get Session

Once a user is logged in, you often want to get the session object in order to use the data in some way. A common use-case is to show their profile picture or display some other user information.

./components/UserAvatar
import { auth } from "../auth"
 
export default async function UserAvatar() {
  const session = await auth()
 
  if (!session.user) return null
 
  return (
    <div>
      <img src={session.user.img} alt="User Avatar" />
    </div>
  )
}
Auth.js © Balázs Orbán and Team - 2024