
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, you can definitely set initial values for an array of objects like that! Sanity supports the initialValue property on fields, and it works with arrays of objects too.
For your specific schema, you can add initialValue at the array level. Here's how:
{
title: "Media",
name: "media",
type: "array",
initialValue: [
{
_type: "image",
// You can't really pre-populate image assets, but the type is set
},
{
_type: "object",
_key: "video-default", // Arrays need unique _key values
url: "https://example.com/default-video.mp4",
autoplay: false,
controls: true,
},
],
of: [
{
title: "Image",
type: "image",
},
{
title: "Video",
type: "object",
fields: [
{
title: "Video Url",
name: "url",
type: "url",
},
{
title: "Autoplay",
name: "autoplay",
type: "boolean",
initialValue: false, // Field-level default
},
{
title: "Controls",
name: "controls",
type: "boolean",
initialValue: true, // Field-level default
},
],
},
],
}A few important notes:
Field-level vs array-level: You can set initialValue on individual fields (like autoplay and controls above) which will apply whenever someone adds a new video object to the array. This is often more practical than pre-populating the entire array.
Array items need _type: When setting initial values for arrays with multiple types, each item needs a _type property matching one of the types in your of array.
Dynamic initial values: If you need more complex logic, initialValue can be a function:
initialValue: () => [{
_type: "object",
autoplay: false,
controls: true,
url: ""
}]sanity.config.ts file.The field-level approach (setting initialValue on autoplay and controls) is usually the most maintainable solution for your use case, as it ensures every new video object gets sensible defaults without pre-populating the entire array.
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