✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Warning: userStore.currentUser is deprecated

The userStore.currentUser method has been deprecated in favor of userStore.me which is an observable stream of the current logged in user or null if the user is logged out.

Where the userStore.currentUser observable stream emitted a "snapshot" event object with the user object at the user property every time user state changed, the userStore.me emits the user object (or null if logged out) as you would see it from the /users/me API endpoint.

Example of how to migrate existing code currently using userStore.currentUser to instead use userStore.me:

Before

userStore.currentUser.subscribe(event => {
  console.log('Current user is:', event.user)
})

After

userStore.me.subscribe(user => {
  console.log('Current user is:', user)
})

Was this article helpful?