How to show createdAt field in Sanity Studio
Not a dumb question at all! Yes, there are several ways to show the _createdAt field in Sanity Studio.
Quick Option: Show in Preview
The simplest approach is to display it in the document preview using the preview section of your schema:
preview: {
select: {
title: "title",
created: "_createdAt",
},
prepare({ title, created }) {
return {
title: title,
subtitle: created
}
}
}Display as a Field in the Document
If you want to show _createdAt as an actual field inside the document form, you'll need to create a custom input component. Here's a working solution from this community answer:
1. Create the custom component:
import React from 'react';
import { Card, Text } from '@sanity/ui';
import { withDocument } from 'part:@sanity/form-builder';
const CreatedAt = React.forwardRef((props, ref) => {
return (
<Card padding={[3, 3, 4]} radius={2} shadow={1} tone='positive'>
<Text align='center' size={[2, 2, 3]}>
Created at {props.document._createdAt}
</Text>
</Card>
);
});
export default withDocument(CreatedAt);2. Add it to your schema:
{
name: 'createdAtDisplay',
title: 'Created At Display',
type: 'string',
inputComponent: CreatedAt
}This field won't actually store any data (since there's no input), but it will display the _createdAt value from the document. You can also format the date, add styling, or even run GROQ queries within the component using useEffect if you need more complex functionality.
Note: If you're using Studio v3, the import paths and approach would be slightly different - you'd use @sanity/ui and the new component API instead of part:@sanity/form-builder.
Alternative: Check Document History
You can also simply check the document's version history in Studio to see when it was created and last edited, though this is less visible than the above options.
Show original thread19 replies
Sanity – Build the way you think, not the way your CMS thinks
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.