npm / @sanity/client
@sanity/client
What changed in @sanity/client 4 to 8, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-20.
27 breaking1 deprecations43 new APIs and options1 performance21 behavior and defaults4 tooling25 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@sanity/client 885 changes
Breaking changes 21
Context issues now have only the conflict and update_required kinds.
Each action addresses a variant document by the publishedId, variantId and bundleId triple rather than by document ID.
Adds variant action types to the Action union, so client.action() accepts them; exhaustive switches on Action['actionType'] must handle the new cases.
DNS ENOTFOUND errors are retried for idempotent requests; set maxRetries to 0 to fail immediately.
Consumers must resolve the package through exports after the main and module package fields are removed.
Changes to this environment variable after process startup no longer affect requests.
This event type is removed; observable asset uploads now emit UploadEvent<T>.
The main package field is removed; consumers must resolve the package through exports.
The module package field is removed; consumers must resolve the package through exports.
Node 22.12 or higher is required to use the package.
Progress events are emitted only in browsers; Node and edge runtimes emit only the terminal response event.
The per-request proxy option is removed; configure proxy on the client or through proxy environment variables.
The client config option is removed; use headers configuration and a custom fetch instead.
The deprecated internal client config option is removed.
The RequestHandler type is removed.
The package is ESM-only and no longer ships CommonJS runtime or declaration files.
typesVersions declarations are removed; TypeScript moduleResolution must be node16, nodenext, or bundler.
The UMD bundle is removed from the distribution; use a bundler or a service such as esm.sh.
The unstable__adapter export is removed.
The unstable__environment export is removed.
Observable asset uploads now emit UploadEvent<T> instead of the removed event types.
Deprecations 1
range, top-level fieldValue, and range: null are deprecated; they are still accepted and sent as anchor.
New APIs and options 28
Context can check and draft instructions, and branch on typed API error codes.
Build stages publish their order and weight.
Knowledge bases, imports, and sources now report their source chunks.
MCP endpoint dataset sources now carry workspace, perspective, and semanticSearch.
Adds a reactive auth config option for credentials that change during the client's lifetime; requests and reconnects wait for pending credential renewal.
Resolves to the credential the client would send right now.
Emits the current credential and every change.
Adds support for Durable function callbacks.
Adds a type that reads params from the query's __groqParams brand.
Can create, edit, and delete endpoints.
Reads an endpoint by name.
Adds conversations.delete.
Comment create and update now accept a typed anchor with type "portable-text" and optional fieldValue.
Exported from @sanity/client/collaboration to build a collaboration comment's global document reference from a resource and document ID without a client.
Adds a per-resource projection registry with a document-type level because projections resolve against the caller's document handle.
Adds a per-resource query registry for consumers that perform resource-aware lookups.
Adds a per-resource schema registry so consumers can register different result types for resources whose schemas disagree.
Adds context APIs for knowledge bases, builds, triage, telemetry, and GROQ reads.
Supports status, importId, and ids filters.
Datasets now have a description field.
Invocation now accepts an options argument and supports durable and queue functions. Calls are queued by default and resolve with undefined once accepted; {sync: true} waits for a pubsub function to finish and returns its value.
Adds a collaboration comments client, marked alpha.
Invoke deployed sanity.function.pubsub functions by name; the promise-based form resolves with the function's return value.
Observable invocation emits the function result and accepts an event.data payload, a per-call timeout and an AbortSignal.
Exports the Media Library asset shape, which tracks uploaded versions via currentVersion and versions.
Reach stacks deployed at organization scope with a client config option; organizationId takes precedence over projectId, which becomes optional.
A request handler is available for client integrations.
Configure a stackId on the client to resolve function names, which are unique only within a stack; resolution costs one extra request per call.
Behavior and default changes 14
The Context API is called through one request typed from its spec.
Knowledge bases no longer have a document limit.
The comments API is promoted to beta.
Under reactive auth, config().token is undefined because config() describes what was configured; use client.getAuth() to read the credential the client sends.
Infers result and params types from a query branded with __groqResult and __groqParams, without a generic argument or SanityQueries entry; brand reading is experimental.
Follows the citation redesign.
Checks params from a query's __groqParams brand; brand reading is experimental.
instructions.delete can start a rebuild and returns its job.
The default filter denylist now includes mux video machine fields.
Comment writes now send clientVersion.
Debug output is dropped for browser uploads.
Error messages now include the HTTP status text.
A caller-provided internal config.resolveFetch takes precedence over the environment resolver.
Set maxRetries to 0 to fail immediately on DNS ENOTFOUND errors.
Tooling 4
Types each job's kind and result.
Types are updated with the latest Context API descriptions, helping developers use the current context API accurately.
Use TypeScript moduleResolution set to node16, nodenext, or bundler.
Editor autocomplete is restored for its template literal patterns without changing assignability.
Fixes and other changes 17
Checks EventSource compatibility before using it.
Restores the context namespaces called by Sanity CLI 8.27, alongside request.
When retrying, treats a request with a body and no method as POST.
Supports Node.js stream bodies in Deno, workerd and react-server.
Fixes requests and asset uploads using Node.js streams in Bun, resolving “Unsupported body type: object” errors during Studio deployments.
Context API types now include the error body and every path parameter.
The underlying EventSource request is aborted when the response fails validation.
Requests are retried on React Native.
A nullish apiHost now uses the default host.
The DatasetsResponse type was updated.
Collaboration resolves a comment range from the optional fieldValue.
Uploads against a Media Library now resolve to the uploaded asset instead of undefined; Content Lake responses continue to unwrap document.
The /check/cors probe now uses the same resolved fetch as the EventSource connection, applying custom resolveFetch or an explicit proxy.
Without options, delete() now correctly types as resolving to MultipleMutationResult rather than SanityDocument<R>, matching unchanged runtime behavior.
Server-sent event IDs are now populated on Cloudflare Workers for client.live.events() and client.listen().
Without options, mutate() now correctly types as resolving to MultipleMutationResult rather than SanityDocument<R>, matching unchanged runtime behavior.
Editor autocomplete is restored for published and drafts without changing assignability.
@sanity/client 727 changes
Breaking changes 2
The resource guard was removed from the live client.
Support for Node.js versions below 20 was dropped; Node.js 20 or later is required.
New APIs and options 14
Query result types can be registered on a global SanityQueries interface, and client return types resolve registrations from either the global interface or the existing module augmentation.
Queries can now use multiple variant conditions.
Adds branded string types for stega-encoded results, allowing developers to distinguish those results in types.
Adds variant querying.
Adds documentsExists for batch existence checks.
Adds a waitFor option to defer live events until Sanity Function processing.
Adds an internal requestHandler configuration option for intercepting requests.
Listing projects accepts more query options, allowing developers to customize project-listing queries.
Adds VideoSubtitleInfo types to playback info.
Adds VideoRenditionInfo types with typed resolution.
Adds the onlyExplicitMembership option to projects.list().
Added embeddings configuration options for datasets.
Adds support for resuming listener events.
Adds thumbHash support to AssetMetadataType, using the corrected field casing.
Behavior and default changes 4
Improves get-it HTTP stacktraces.
Trace IDs from backend responses are exposed on errors, helping developers identify and investigate requests.
Improves Media Library API support.
The event type returned by listen is based on options.events.
Fixes and other changes 7
Symbol-keyed properties are kept unbranded in StegaBranded.
Rejected live/listen connections with a 4xx response are no longer reconnected.
The live client verifies CORS via /check/cors with credentials awareness before reporting CorsOriginError.
Stega now allows zero-width space characters in content.
Fixed resolution of root path mappings in CSM.
Stega encoding was improved, which may affect its performance.
The releaseId parameter is now optional when calling createVersion.
@sanity/client 63 changes
Breaking changes 1
useCdn now defaults to true, so queries made from the front end use the CDN; set useCdn: false when every query needs fresh data.
Behavior and default changes 2
The client automatically retries GET/HEAD requests and queries after 429, 502, or 503 responses and socket/DNS errors. Applications with custom retry code can disable client retries with maxRetries: 0 or adjust retryDelay and maxRetries.
request() is no longer deprecated.
@sanity/client 55 changes
Breaking changes 2
A named createClient export replaces the default export for creating a client.
The default export was removed; import the client using the named createClient export instead.
New APIs and options 1
httpRequest on SanityClient is configurable, intended for libraries wishing to extend the client.
Performance 1
The package ships modern syntax to reduce bundle size.
Behavior and default changes 1
The client now has full Node.js ESM runtime support.
@sanity/client 42 changes
Breaking changes 1
ESM support was expanded; backward compatibility cannot be guaranteed across all conditions, environments, and runtime versions.
Fixes and other changes 1
ESM output was improved to support Deno, Bun, and Edge runtimes.