Skip to content

Accessing currentUser in V3 studio. #3548

Aug 22, 2022 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

For Structure Builder specifically, you can do something like this in v3:

import {ConfigContext, createConfig} from 'sanity'
import {deskTool, StructureBuilder} from 'sanity/desk'
import {schemaTypes} from './schemas'

export default createConfig({
  name: 'default',
  title: 'sanity-v3-structure-builder',

  projectId: 'your-projectId',
  dataset: 'your-dataset',
  plugins: [
    deskTool({
      structure: (S: StructureBuilder, context: ConfigContext) => {
        const {projectId, dataset, schema, currentUser, client} = context
        const {id, name, email, profileImage, provider, roles} = currentUser
		if(!currentUser) {
			return S.list().title('User missing')
		}

        // your …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by kmelve
Comment options

You must be logged in to vote
1 reply
@snorrees
Comment options

Comment options

You must be logged in to vote
1 reply
@snorrees
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants