Join live – Get insights, tips, + Q&A from Sanity developers on our latest releases

Warning: userStore.currentUser is deprecated

The userStore.currentUser method has been deprecated in favor of 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 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.currentUser.subscribe(event => {
  console.log('Current user is:', event.user)

After => {
  console.log('Current user is:', user)

Was this article helpful?