I'm trying to fetch the current user in Sanity CMS.
I found this code snippet which demonstrates use of userStore
But I don't understand how I can configure my project to accept this module lookup
import userStore from 'part:@sanity/base/user';
It throws an import error Cannot find module 'part:@sanity/base/user'
. Which makes sense as its a non standard node module.
- How can I resolve this so the module is found?
- Or alternatively anyone know another way to fetch the current user?
Inspecting that @sanity
source I can see base/lib/datastores
which has a userStore
it's just not obvious how to consume this.
So this example hook works and returns the User. Sanity is taking care of the module resolution. It's an IDE error not a runtime error in Sanity.
(╯°□°)╯︵ ┻━┻
Their advice is to ignore these un resolved module warnings for part imports.