Sanity Content Relationships: Document References vs. Portable Text Embeds
Decide between Sanity document references and Portable Text embeds for content relationships: a comparison table, trade-offs, schema code, and GROQ validation.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Decide between Sanity document references and Portable Text embeds for content relationships: a comparison table, trade-offs, schema code, and GROQ validation.
Portable Text lets you model rich content as typed blocks and transform it per channel with GROQ instead of rendering HTML everywhere. Use schema-defined custom blocks and serializer maps for portable, safe content.
Learn how to use the Sanity Studio v3 Structure Builder to move beyond flat lists, create filtered document views, and implement conditional field visibility for a professional editing workflow.
Learn how to cut network traffic and improve Studio performance by pushing filtering and pagination to Sanity’s GROQ engine. A practical example, trade‑offs, and actionable steps are included.
Identify why a GROQ query takes >2 seconds, apply targeted checks, and apply fixes that reduce latency while preserving UI functionality.
GROQ projections let you shape Sanity query results server-side — flattening references, generating excerpts, and matching your component props exactly. Here's a worked example plus the trade-offs.
Bare Sanity queries over-fetch and force extra round-trips for references. Learn how GROQ projections and the -> dereference operator let you shape exactly the JSON your components need, server-side.
Sanity keeps drafts in the same dataset as published content. The minimal design: one query set, two clients, and the published vs. previewDrafts perspectives as the trust boundary.
GROQ paginates with an inclusive slice operator applied after filtering and ordering. Here's the query shape, a working route handler, and the offset pitfalls to check before shipping.