
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeIn Sanity Studio, you can access information about the currently logged-in user, including their user ID, email address, and other details. There are two main approaches depending on your Studio version:
The Studio exports a built-in hook called useCurrentUser that you can import directly:
import { useCurrentUser } from "sanity"
function MyComponent() {
const currentUser = useCurrentUser()
// Access user properties
console.log(currentUser?.id)
console.log(currentUser?.email)
console.log(currentUser?.name)
return <div>Welcome, {currentUser?.name}</div>
}If you're still on Studio v2, you can use the older import path:
import { useCurrentUser } from "@sanity/base/hooks"Or create your own custom hook using the user store:
import userStore from 'part:@sanity/base/user'
import { useEffect, useState } from 'react'
export function useCurrentUser() {
const [user, setUser] = useState({})
useEffect(() => {
userStore.currentUser.subscribe(e => setUser(e.user))
}, [])
return user
}This is particularly useful when you want to:
The user object typically includes properties like id, email, name, and roles, which you can use to customize the Studio experience based on who's logged in.
You can find more details in the useCurrentUser recipe on Sanity's documentation.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store