Build with Sanity MCP in Replit. Prizes up for grabs! Submit by June 14

How to add rich text block inside array of structured content in Sanity?

7 repliesLast updated: Nov 29, 2025

Hey there! How to add a rich text block inside an array of structured content?I have this object for the content:


{
      title: "Content",
      name: "content",
      type: "array",
      group: "countryInfo",
      of: [
        // { type: "block" },
        { type: "textBlock" },
        { type: "image" },
        { type: "speedTest" },
        { type: "thePricingTable" },
      ],
    },
the `textBlock`object is this:

export default {
  name: "textBlock",
  title: "Text Block",
  type: "array",

  of: [{ type: "block" }],
};
but i get this error:
AI Update

I can see the issue! You're trying to nest an array inside another array, which causes this error in Sanity. The problem is that your textBlock is defined as type: "array", and you're trying to use it inside another array field.

The solution is to define textBlock as an object type, not an array type:

export default {
  name: "textBlock",
  title: "Text Block",
  type: "object", // Changed from "array" to "object"
  fields: [
    {
      name: "content",
      title: "Content",
      type: "array",
      of: [{ type: "block" }],
    }
  ]
};

Now your main content array will work properly:

{
  title: "Content",
  name: "content",
  type: "array",
  group: "countryInfo",
  of: [
    { type: "textBlock" }, // This now references an object, not an array
    { type: "image" },
    { type: "speedTest" },
    { type: "thePricingTable" },
  ],
}

Why this works: In Sanity, when you have an array field, the items in the of array can be either:

But you cannot directly nest arrays within arrays. By making textBlock an object type that contains an array field, you follow Sanity's schema structure correctly.

Alternative approach: If you just want rich text directly in your content array without the extra wrapper, you can simply use:

{
  title: "Content",
  name: "content",
  type: "array",
  of: [
    { type: "block" }, // Rich text directly
    { type: "image" },
    { type: "speedTest" },
    { type: "thePricingTable" },
  ],
}

This gives you Portable Text rich text editing capabilities mixed with your custom block types, which is the standard pattern for Block Content in Sanity.

Show original thread
7 replies

Was this answer helpful?

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.

Related contributions