Fix a Sanity Studio custom form component (components.input, components.field, components.item, or a plugin's form.components) that suspends without its own Suspense boundary, so it loads without layout shift and never blocks new documents. Use when the console warns "The custom input/field/item component ... suspended without a <Suspense> boundary of its own" or "A form component ... suspended without a <Suspense> boundary of its own", when a custom form component uses React.lazy, use(), App SDK hooks (useDocumentProjection, useQuery, useDocument) or another suspending data library, or when a field or array item shows a skeleton that never goes away on new documents.
Getting started
Full instructionsInstall the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.
Instructions: SKILL.mdv1.0.0
Custom form components that suspend
Studio puts a fallback boundary around every field and every array item, so one suspending
component cannot blank the form. That fallback is a generic skeleton: it does not know the size of
what it replaces, so the form shifts when the component loads, and Studio warns about it in the
console. The fix always lives in your code: declare a Suspense around the part that suspends,
with a fallback that takes the same space as what it stands in for. Any boundary you declare is
closer to what suspends than Studio's, so it always wins and nothing warns. That includes a
boundary in a custom field around props.renderDefault(props), which also covers the field's
input: use it when one fallback should cover both, for example a lazy input that also fetches.
Workflow
- Find the component. The warning names the custom components declared for that field or
item (components.field,.inputor.item), the path, the document type and the schema type,
and logs the components themselves; click one in the browser console to open its source.
Production builds minify the names, so use the path and document type there. When the schema
type declares none, the warning starts with "A form component" and the culprit is usually a
plugin'sform.components. React DevTools' Suspense tab shows which component actually
suspended. - Find what suspends. Usually one of:
React.lazy,use(promise), an App SDK hook
(useDocumentProjection,useDocument,useQuery,useDocuments), or a library in suspense
mode (useSuspenseQuery). - Move it into its own component if it is not already, and wrap only that component in
<Suspense>inside the custom component. Keepprops.renderDefault(props)outside the
boundary, so the built-in input, field or item never unmounts (and never loses focus while
someone types) when the async part suspends again. - Reserve the space. The fallback must have the size of the loaded UI:
- Additive UI (warnings, previews, counts): render it after
renderDefaultso it never pushes
the rest down, and give the fallback the height of one loaded row. - A whole component that loads lazily: a skeleton with the component's height, not
null. - Array items: the list is virtualized and measures each row, so an item fallback that is
shorter or taller than the loaded row makes the rows below it jump. Match the row height.
- Additive UI (warnings, previews, counts): render it after
- Do not suspend on a document that does not exist yet. A new document only exists once the
first edit creates it, and SDK hooks that read the current document wait for it forever. Gate
onuseFormValue(['_createdAt']): it is unset until the document exists. - Keep promises stable. A promise created during render, in
useStateor inuseMemois
thrown away while the component suspends on mount, souse()gets a new one every retry and
never settles. Use the SDK hooks, a module-scope cache keyed by the inputs, or a data library. - Verify. Open a new document of the type and an existing one: the warning is gone, the rest
of the form is editable right away, and nothing moves when the async part lands.
Example
import {createDocumentHandle, useDocumentProjection} from '@sanity/sdk-react'
import {Card, Skeleton, Stack, Text} from '@sanity/ui'
import {Suspense} from 'react'
import {type ArrayOfObjectsInputProps, getPublishedId, useFormValue} from 'sanity'
export function ModelSizeInput(props: ArrayOfObjectsInputProps) {
const documentId = useFormValue(['_id']) as string
const documentExists = Boolean(useFormValue(['_createdAt']))
const hasModels = (props.value?.length ?? 0) > 0
return (
<Stack gap={3}>
{props.renderDefault(props)}
{documentExists && hasModels ? (
<Suspense fallback={<Skeleton radius={2} style={{height: 33}} animated />}>
<ModelSizeWarnings documentId={getPublishedId(documentId)} />
</Suspense>
) : null}
</Stack>
)
}
function ModelSizeWarnings(props: {documentId: string}) {
const {data} = useDocumentProjection<{missing: number}>({
...createDocumentHandle({documentType: 'product', documentId: props.documentId}),
projection: `{"missing": count(models[!defined(@->size)])}`,
})
return (
<Card padding={2} radius={2} tone={data.missing > 0 ? 'critical' : 'positive'}>
<Text size={1}>{data.missing} models are missing a size</Text>
</Card>
)
}
The skeleton's height matches the one-line card it stands in for. If the loaded UI's height
varies, reserve the most common case and keep the variable part below the input.
Explore more skills
Browse all- Sanity MigrationPlans, implements, and reviews migrations from other CMSes and content systems into Sanity. Use when migrating or…
- Sanity Studio ListenersKeep Sanity Studio customizations (custom tools, inputs, document views, structure and plugins) from opening a…
- Sanity SingletonsConfigure singleton documents in a Sanity Studio using the document.singletons registry. Use when a developer wants a…
- Sanity Studio UpgradeProduces a tailored Sanity Studio upgrade plan by inspecting the repository's installed versions, config, and source,…
- Senior FrontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle…
- UI Design SystemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens…
Security
Reviews (0)
More from Sanity
View source →Frequently asked questions about sanity-form-component-suspense
What does the sanity-form-component-suspense skill do?
Fix a Sanity Studio custom form component (components.input, components.field, components.item, or a plugin's form.components) that suspends without its own Suspense boundary, so it loads without layout shift and never blocks new documents. Use when the console warns "The custom input/field/item component ... suspended without a <Suspense> boundary of its own" or "A form component ... suspended without a <Suspense> boundary of its own", when a custom form component uses React.lazy, use(), App SDK hooks (useDocumentProjection, useQuery, useDocument) or another suspending data library, or when a field or array item shows a skeleton that never goes away on new documents. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the sanity-form-component-suspense skill?
Run `npx @skills-hub-ai/cli install sanity-form-component-suspense` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/sanity-form-component-suspense/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does sanity-form-component-suspense work with?
sanity-form-component-suspense runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the sanity-form-component-suspense skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use sanity-form-component-suspense after installing it?
In Claude Code, type `/sanity-form-component-suspense` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the sanity-form-component-suspense skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/sanity-form-component-suspense)<a href="https://skills-hub.ai/skills/sanity-form-component-suspense"><img src="https://skills-hub.ai/api/badges/skill/sanity-form-component-suspense" alt="Install on Skills Hub"></a>More options in the badge docs.