
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! Referencing Sanity account users as authors is a common need. Since Sanity account users aren't stored as documents in your Content Lake (they exist at the project/organization level), you can't create traditional document references to them directly. Here's the recommended approach:
For most content-driven projects, creating a dedicated author document type gives you the most flexibility and is the standard approach:
defineType({
name: 'author',
type: 'document',
fields: [
defineField({name: 'name', type: 'string'}),
defineField({name: 'email', type: 'string'}),
defineField({name: 'userId', type: 'string', title: 'Sanity User ID'}),
defineField({name: 'bio', type: 'text'}),
defineField({name: 'photo', type: 'image'}),
defineField({name: 'socialLinks', type: 'array', of: [{type: 'url'}]})
]
})Then use a standard reference in your content documents:
defineField({
name: 'author',
type: 'reference',
to: [{type: 'author'}]
})Why this approach works best:
If you want to automatically populate author information when a document is created, you can use initial value templates. The currentUser object is available in the template context:
// In your sanity.config.ts
export default defineConfig({
// ... other config
document: {
newDocumentOptions: (prev, context) => {
return [
...prev,
{
id: 'article-with-author',
title: 'Article',
schemaType: 'article',
value: () => ({
authorName: context.currentUser?.name,
authorEmail: context.currentUser?.email,
authorId: context.currentUser?.id
})
}
]
}
}
})In your schema, define fields to store this information:
defineField({
name: 'authorId',
type: 'string',
title: 'Author ID',
readOnly: true
}),
defineField({
name: 'authorName',
type: 'string',
title: 'Author Name',
readOnly: true
})Pros: Automatic capture of who created the document, minimal setup
Cons: Values are snapshots at creation time - if a user changes their name later, existing documents won't update automatically; limited to basic user info (name, email, ID)
You can combine both methods by storing the userId in your author documents to maintain a link to Sanity account users while still having rich author profiles:
defineType({
name: 'author',
type: 'document',
fields: [
defineField({
name: 'sanityUserId',
type: 'string',
title: 'Sanity User ID',
description: 'Links this author to their Sanity account'
}),
// ... other author fields
]
})This gives you the best of both worlds - rich author content plus a connection to actual Sanity users for permissions and workflows.
For most blogs, news sites, or content platforms where authors are displayed publicly, the separate author documents approach (first option) is definitely the way to go!
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