Batch multiple queries in a single API call and drop in queryParams using the structure above.
Yes! Sanity supports batching multiple operations, but it depends on whether you're doing writes (mutations) or reads (queries).
For mutations (writes): Sanity has built-in support for batching through transactions. Transactions allow you to bundle multiple creates, updates, and deletes into a single atomic API call where either all changes succeed or all fail together:
import {client} from './sanityClient'
const transaction = client.transaction()
.create({_type: 'post', title: 'First post'})
.patch('doc-id-123', p => p.set({title: 'Updated title'}))
.delete('doc-id-456')
await transaction.commit()This sends all three operations in one HTTP request with ACID-compliant guarantees.
For queries (reads): Sanity doesn't currently offer a native batch query API that lets you execute multiple separate GROQ queries in a single HTTP request. Each client.fetch() call is a separate API request.
However, you have these alternatives:
- Combine queries using GROQ projections - Structure a single query to fetch multiple datasets:
const data = await client.fetch(`{
"posts": *[_type == "post"],
"authors": *[_type == "author"],
"categories": *[_type == "category"]
}`)Use Sanity Functions - Create a serverless function that executes multiple queries server-side and returns combined results, reducing round trips from your client.
Leverage GROQ joins and references - Fetch related data in one query using references and projections rather than multiple separate queries.
So while there's no "batch query API" like some platforms offer, the transaction API handles mutation batching well, and GROQ's flexibility lets you consolidate most read operations into efficient single queries.
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.