@sanity/sdk-react 3.0.0-rc.0 → 3.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +103 -155
  2. package/dist/index.d.ts +1564 -682
  3. package/dist/index.js +1118 -612
  4. package/dist/index.js.map +1 -1
  5. package/package.json +51 -54
  6. package/src/_exports/index.ts +2 -4
  7. package/src/_exports/sdk-react.ts +26 -17
  8. package/src/components/SDKProvider.test.tsx +173 -32
  9. package/src/components/SDKProvider.tsx +87 -28
  10. package/src/components/SanityApp.test.tsx +68 -12
  11. package/src/components/SanityApp.tsx +94 -87
  12. package/src/components/auth/AuthBoundary.recovery.test.tsx +86 -0
  13. package/src/components/auth/AuthBoundary.test.tsx +26 -8
  14. package/src/components/auth/AuthBoundary.tsx +28 -6
  15. package/src/components/auth/DashboardAccessRequest.tsx +37 -0
  16. package/src/components/auth/LoginError.test.tsx +191 -5
  17. package/src/components/auth/LoginError.tsx +103 -59
  18. package/src/components/errors/ChunkLoadError.test.tsx +59 -0
  19. package/src/components/errors/ChunkLoadError.tsx +56 -0
  20. package/src/components/errors/CorsErrorComponent.tsx +2 -2
  21. package/src/components/errors/chunkReloadStorage.ts +57 -0
  22. package/src/config/handles.ts +29 -27
  23. package/src/constants.ts +5 -0
  24. package/src/context/ComlinkTokenRefresh.test.tsx +10 -27
  25. package/src/context/DefaultResourceContext.ts +3 -3
  26. package/src/context/OrganizationResourcesProvider.test.tsx +189 -0
  27. package/src/context/OrganizationResourcesProvider.tsx +111 -0
  28. package/src/context/PerspectiveContext.ts +3 -3
  29. package/src/context/ProjectContext.ts +15 -0
  30. package/src/context/ResourceProvider.test.tsx +72 -90
  31. package/src/context/ResourceProvider.tsx +59 -93
  32. package/src/context/SDKStudioContext.test.tsx +28 -33
  33. package/src/context/SanityInstanceProvider.test.tsx +100 -0
  34. package/src/context/SanityInstanceProvider.tsx +71 -0
  35. package/src/context/WorkbenchTokenRefresh.test.tsx +106 -0
  36. package/src/context/WorkbenchTokenRefresh.tsx +61 -0
  37. package/src/context/renderSanityApp.test.tsx +151 -49
  38. package/src/context/renderSanityApp.tsx +12 -8
  39. package/src/context/workbenchToken.ts +63 -0
  40. package/src/hooks/access/useCheckPermissions.test-d.ts +15 -0
  41. package/src/hooks/access/useCheckPermissions.test.tsx +53 -0
  42. package/src/hooks/access/useCheckPermissions.ts +24 -0
  43. package/src/hooks/agent/agentActions.test.tsx +1 -1
  44. package/src/hooks/agent/agentActions.ts +51 -71
  45. package/src/hooks/applications/useApplication.test-d.ts +30 -0
  46. package/src/hooks/applications/useApplication.ts +22 -0
  47. package/src/hooks/applications/useApplications.test-d.ts +31 -0
  48. package/src/hooks/applications/useApplications.ts +25 -0
  49. package/src/hooks/applications/useCreateUserApplication.test-d.ts +14 -0
  50. package/src/hooks/applications/useCreateUserApplication.ts +11 -0
  51. package/src/hooks/applications/useDeleteApplication.test-d.ts +12 -0
  52. package/src/hooks/applications/useDeleteApplication.ts +11 -0
  53. package/src/hooks/applications/useDeleteUserApplication.test-d.ts +14 -0
  54. package/src/hooks/applications/useDeleteUserApplication.ts +11 -0
  55. package/src/hooks/applications/useUpdateApplication.test-d.ts +12 -0
  56. package/src/hooks/applications/useUpdateApplication.ts +11 -0
  57. package/src/hooks/applications/useUpdateUserApplication.test-d.ts +14 -0
  58. package/src/hooks/applications/useUpdateUserApplication.ts +11 -0
  59. package/src/hooks/applications/useUserApplication.test-d.ts +11 -0
  60. package/src/hooks/applications/useUserApplication.ts +14 -0
  61. package/src/hooks/applications/useUserApplications.test-d.ts +11 -0
  62. package/src/hooks/applications/useUserApplications.ts +14 -0
  63. package/src/hooks/auth/useDashboardOrganizationId.test.tsx +2 -8
  64. package/src/hooks/auth/useVerifyOrgProjects.test.tsx +8 -32
  65. package/src/hooks/auth/useVerifyOrgProjects.tsx +13 -6
  66. package/src/hooks/client/useClient.test.tsx +1 -4
  67. package/src/hooks/client/useClient.ts +1 -0
  68. package/src/hooks/context/useResource.test.tsx +32 -0
  69. package/src/hooks/context/useResource.ts +24 -0
  70. package/src/hooks/context/useSanityInstance.test.tsx +72 -3
  71. package/src/hooks/context/useSanityInstance.ts +30 -8
  72. package/src/hooks/dashboard/useManageFavorite.test.tsx +110 -46
  73. package/src/hooks/dashboard/useManageFavorite.ts +10 -16
  74. package/src/hooks/dashboard/useNavigateToStudioDocument.test.ts +5 -7
  75. package/src/hooks/dashboard/useNavigateToStudioDocument.ts +2 -6
  76. package/src/hooks/dashboard/useRecordDocumentHistoryEvent.test.ts +0 -2
  77. package/src/hooks/dashboard/useRecordDocumentHistoryEvent.ts +1 -2
  78. package/src/hooks/dashboard/useWindowTitle.test.ts +244 -0
  79. package/src/hooks/dashboard/useWindowTitle.ts +114 -0
  80. package/src/hooks/datasets/useDatasets.test.tsx +116 -0
  81. package/src/hooks/datasets/useDatasets.ts +33 -13
  82. package/src/hooks/document/useApplyDocumentActions.test.tsx +48 -0
  83. package/src/hooks/document/useApplyDocumentActions.ts +66 -48
  84. package/src/hooks/document/useCreateDocument.test.tsx +83 -0
  85. package/src/hooks/document/useCreateDocument.ts +117 -0
  86. package/src/hooks/document/useDocument.test.tsx +37 -8
  87. package/src/hooks/document/useDocument.ts +131 -66
  88. package/src/hooks/document/useDocumentEvent.test.tsx +16 -4
  89. package/src/hooks/document/useDocumentEvent.ts +16 -10
  90. package/src/hooks/document/useDocumentPermissions.test.tsx +8 -7
  91. package/src/hooks/document/useDocumentPermissions.ts +71 -39
  92. package/src/hooks/document/useDocumentSyncStatus.test.ts +1 -0
  93. package/src/hooks/document/useDocumentSyncStatus.ts +13 -9
  94. package/src/hooks/document/useEditDocument.test.tsx +21 -14
  95. package/src/hooks/document/useEditDocument.ts +163 -17
  96. package/src/hooks/documents/useDocuments.test.tsx +64 -44
  97. package/src/hooks/documents/useDocuments.ts +36 -20
  98. package/src/hooks/helpers/createCallbackHook.test.tsx +13 -19
  99. package/src/hooks/helpers/createFetcherHook.test.tsx +180 -0
  100. package/src/hooks/helpers/createFetcherHook.ts +69 -0
  101. package/src/hooks/helpers/createMutationHook.test.tsx +125 -0
  102. package/src/hooks/helpers/createMutationHook.tsx +93 -0
  103. package/src/hooks/helpers/createStateSourceHook.test.tsx +10 -10
  104. package/src/hooks/helpers/createStateSourceHook.tsx +2 -1
  105. package/src/hooks/{document/useApplyDocumentActions.test.ts → helpers/useApplyActions.test.tsx} +92 -53
  106. package/src/hooks/helpers/useApplyActions.ts +68 -0
  107. package/src/hooks/helpers/useNormalizedResourceOptions.test.tsx +253 -0
  108. package/src/hooks/helpers/useNormalizedResourceOptions.ts +92 -50
  109. package/src/hooks/helpers/useResolvedProjectId.test.tsx +59 -0
  110. package/src/hooks/helpers/useResolvedProjectId.ts +35 -0
  111. package/src/hooks/helpers/useTrackHookUsage.ts +37 -0
  112. package/src/hooks/installations/useInstallation.test-d.ts +19 -0
  113. package/src/hooks/installations/useInstallation.ts +22 -0
  114. package/src/hooks/installations/useInstallations.test-d.ts +26 -0
  115. package/src/hooks/installations/useInstallations.ts +25 -0
  116. package/src/hooks/organizations/useOrganization.test-d.ts +60 -0
  117. package/src/hooks/organizations/useOrganization.test.ts +63 -0
  118. package/src/hooks/organizations/useOrganization.ts +34 -0
  119. package/src/hooks/organizations/useOrganizations.test-d.ts +68 -0
  120. package/src/hooks/organizations/useOrganizations.test.ts +63 -0
  121. package/src/hooks/organizations/useOrganizations.ts +39 -0
  122. package/src/hooks/paginatedDocuments/usePaginatedDocuments.test.tsx +34 -27
  123. package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +40 -22
  124. package/src/hooks/presence/usePresence.test.tsx +0 -15
  125. package/src/hooks/presence/usePresence.ts +9 -20
  126. package/src/hooks/preview/useDocumentPreview.test.tsx +0 -1
  127. package/src/hooks/preview/useDocumentPreview.tsx +10 -8
  128. package/src/hooks/projection/useDocumentProjection.test.tsx +78 -9
  129. package/src/hooks/projection/useDocumentProjection.ts +81 -2
  130. package/src/hooks/projects/useProject.test-d.ts +56 -0
  131. package/src/hooks/projects/useProject.test.tsx +120 -0
  132. package/src/hooks/projects/useProject.ts +42 -43
  133. package/src/hooks/projects/useProjects.test-d.ts +60 -0
  134. package/src/hooks/projects/useProjects.test.ts +45 -98
  135. package/src/hooks/projects/useProjects.ts +19 -26
  136. package/src/hooks/query/useQuery.test.tsx +6 -5
  137. package/src/hooks/query/useQuery.ts +91 -9
  138. package/src/hooks/releases/useActiveReleases.test.tsx +13 -7
  139. package/src/hooks/releases/useActiveReleases.ts +28 -24
  140. package/src/hooks/releases/useAllReleases.test.tsx +93 -0
  141. package/src/hooks/releases/useAllReleases.ts +62 -0
  142. package/src/hooks/releases/useApplyReleaseActions.test.tsx +66 -0
  143. package/src/hooks/releases/useApplyReleaseActions.ts +82 -0
  144. package/src/hooks/releases/usePerspective.test.tsx +18 -10
  145. package/src/hooks/releases/usePerspective.ts +13 -17
  146. package/src/hooks/users/useUser.test.tsx +3 -9
  147. package/src/hooks/users/useUser.ts +2 -0
  148. package/src/hooks/users/useUsers.test.tsx +103 -7
  149. package/src/hooks/users/useUsers.ts +37 -3
  150. package/src/utils/resolveOrgResources.test.ts +111 -0
  151. package/src/utils/resolveOrgResources.ts +69 -0
  152. package/src/hooks/context/useDefaultResource.test.tsx +0 -25
  153. package/src/hooks/context/useDefaultResource.ts +0 -30
  154. package/src/hooks/dashboard/useDispatchIntent.test.ts +0 -254
  155. package/src/hooks/dashboard/useDispatchIntent.ts +0 -157
  156. package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.test.ts +0 -107
  157. package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.ts +0 -39
  158. package/src/hooks/datasets/useDatasets.test.ts +0 -66
  159. package/src/hooks/helpers/useNormalizedResourceOptions.test.ts +0 -65
  160. package/src/hooks/projects/useProject.test.ts +0 -79
package/dist/index.d.ts CHANGED
@@ -1,54 +1,81 @@
1
- import {ActionsResult} from '@sanity/sdk'
2
- import {AgentGenerateOptions} from '@sanity/sdk'
3
- import {AgentPatchOptions} from '@sanity/sdk'
4
- import {AgentPatchResult} from '@sanity/sdk'
5
- import {AgentPromptOptions} from '@sanity/sdk'
6
- import {AgentPromptResult} from '@sanity/sdk'
7
- import {AgentResourceOptions} from '@sanity/sdk'
8
- import {AgentTransformOptions} from '@sanity/sdk'
9
- import {AgentTranslateOptions} from '@sanity/sdk'
10
- import {AuthState} from '@sanity/sdk'
11
- import {CanvasResource} from '@sanity/message-protocol'
12
- import {ClientOptions} from '@sanity/sdk'
13
- import {Context} from 'react'
14
- import {CurrentUser} from '@sanity/sdk'
15
- import {DatasetsResponse} from '@sanity/client'
16
- import {DocumentAction} from '@sanity/sdk'
17
- import {DocumentEvent} from '@sanity/sdk'
18
- import {DocumentPermissionsResult} from '@sanity/sdk'
19
- import {DocumentResource} from '@sanity/sdk'
20
- import {FallbackProps} from 'react-error-boundary'
21
- import {FavoriteStatusResponse} from '@sanity/sdk'
22
- import {FrameMessage} from '@sanity/sdk'
23
- import {GetUserOptions} from '@sanity/sdk'
24
- import {GetUsersOptions} from '@sanity/sdk'
25
- import {MediaResource} from '@sanity/message-protocol'
26
- import {PathChangeMessage} from '@sanity/message-protocol'
27
- import {PerspectiveHandle} from '@sanity/sdk'
28
- import {PreviewValue} from '@sanity/sdk'
29
- import {ProjectHandle} from '@sanity/sdk'
30
- import {PropsWithChildren} from 'react'
31
- import {QueryOptions} from '@sanity/sdk'
32
- import {default as React_2} from 'react'
33
- import {ReactElement} from 'react'
34
- import {ReactNode} from 'react'
35
- import {ReleaseDocument} from '@sanity/sdk'
36
- import {SanityClient} from '@sanity/client'
37
- import {SanityConfig} from '@sanity/sdk'
38
- import {SanityDocument} from '@sanity/types'
39
- import {SanityInstance} from '@sanity/sdk'
40
- import {SanityProject} from '@sanity/sdk'
41
- import {SanityProject as SanityProject_2} from '@sanity/client'
42
- import {SanityProjectMember} from '@sanity/client'
43
- import {SanityUser} from '@sanity/sdk'
44
- import {SortOrderingItem} from '@sanity/types'
45
- import {DocumentHandle as StrictDocumentHandle} from '@sanity/sdk'
46
- import {DocumentTypeHandle as StrictDocumentTypeHandle} from '@sanity/sdk'
47
- import {ResourceHandle as StrictResourceHandle} from '@sanity/sdk'
48
- import {StudioResource} from '@sanity/message-protocol'
49
- import {TokenSource} from '@sanity/sdk'
50
- import {UserPresence} from '@sanity/sdk'
51
- import {WindowMessage} from '@sanity/sdk'
1
+ import { AccessResourceType } from "@sanity/sdk";
2
+ import { ActionsResult } from "@sanity/sdk";
3
+ import { AgentGenerateOptions } from "@sanity/sdk";
4
+ import { AgentPatchOptions } from "@sanity/sdk";
5
+ import { AgentPatchResult } from "@sanity/sdk";
6
+ import { AgentPromptOptions } from "@sanity/sdk";
7
+ import { AgentPromptResult } from "@sanity/sdk";
8
+ import { AgentTransformOptions } from "@sanity/sdk";
9
+ import { AgentTranslateOptions } from "@sanity/sdk";
10
+ import { Application } from "@sanity/sdk";
11
+ import { ApplicationBase } from "@sanity/sdk";
12
+ import { ApplicationInclude } from "@sanity/sdk";
13
+ import { ApplicationsOptions } from "@sanity/sdk";
14
+ import { ApplicationsResponse } from "@sanity/sdk";
15
+ import { AuthState } from "@sanity/sdk";
16
+ import { CanvasResource } from "@sanity/message-protocol";
17
+ import { ClientOptions } from "@sanity/sdk";
18
+ import { Context } from "react";
19
+ import { CreateUserApplicationInput } from "@sanity/sdk";
20
+ import { CurrentUser } from "@sanity/sdk";
21
+ import { DatasetHandle } from "@sanity/sdk";
22
+ import { DatasetsResponse } from "@sanity/client";
23
+ import { DeleteApplicationInput } from "@sanity/sdk";
24
+ import { DeletedResult } from "@sanity/sdk";
25
+ import { DeleteUserApplicationInput } from "@sanity/sdk";
26
+ import { DocumentAction } from "@sanity/sdk";
27
+ import { DocumentEvent } from "@sanity/sdk";
28
+ import { DocumentHandle as DocumentHandle_2 } from "@sanity/sdk";
29
+ import { DocumentOptions } from "@sanity/sdk";
30
+ import { DocumentPermissionsResult } from "@sanity/sdk";
31
+ import { DocumentResource } from "@sanity/sdk";
32
+ import { DocumentTypeHandle as DocumentTypeHandle_2 } from "@sanity/sdk";
33
+ import { FallbackProps } from "react-error-boundary";
34
+ import { FavoriteStatusResponse } from "@sanity/sdk";
35
+ import { FrameMessage } from "@sanity/sdk";
36
+ import { GetUserOptions } from "@sanity/sdk";
37
+ import { GetUsersOptions } from "@sanity/sdk";
38
+ import { Installation } from "@sanity/sdk";
39
+ import { InstallationInclude } from "@sanity/sdk";
40
+ import { InstallationsOptions } from "@sanity/sdk";
41
+ import { InstallationsResponse } from "@sanity/sdk";
42
+ import { JsonMatch } from "@sanity/sdk";
43
+ import { MediaResource } from "@sanity/message-protocol";
44
+ import { Organization } from "@sanity/sdk";
45
+ import { OrganizationOptions } from "@sanity/sdk";
46
+ import { Organizations } from "@sanity/sdk";
47
+ import { OrganizationsOptions } from "@sanity/sdk";
48
+ import { PathChangeMessage } from "@sanity/message-protocol";
49
+ import { PreviewValue } from "@sanity/sdk";
50
+ import { Project } from "@sanity/sdk";
51
+ import { ProjectHandle } from "@sanity/sdk";
52
+ import { ProjectOptions } from "@sanity/sdk";
53
+ import { ProjectsOptions } from "@sanity/sdk";
54
+ import { PropsWithChildren } from "react";
55
+ import { QueryOptions } from "@sanity/sdk";
56
+ import { default as React_2 } from "react";
57
+ import { ReactElement } from "react";
58
+ import { ReactNode } from "react";
59
+ import { ReleaseAction } from "@sanity/sdk";
60
+ import { ReleaseDocument } from "@sanity/sdk";
61
+ import { SanityClient } from "@sanity/client";
62
+ import { SanityConfig } from "@sanity/sdk";
63
+ import { SanityDocument } from "@sanity/types";
64
+ import { SanityDocument as SanityDocument_2 } from "groq";
65
+ import { SanityInstance } from "@sanity/sdk";
66
+ import { SanityProjectionResult } from "groq";
67
+ import { SanityProjectMember } from "@sanity/client";
68
+ import { SanityQueryResult } from "groq";
69
+ import { SanityUser } from "@sanity/sdk";
70
+ import { SortOrderingItem } from "@sanity/types";
71
+ import { StudioResource } from "@sanity/message-protocol";
72
+ import { TokenSource } from "@sanity/sdk";
73
+ import { UpdateApplicationInput } from "@sanity/sdk";
74
+ import { UpdateUserApplicationInput } from "@sanity/sdk";
75
+ import { UserApplication } from "@sanity/sdk";
76
+ import { UserApplicationsOptions } from "@sanity/sdk";
77
+ import { UserPresence } from "@sanity/sdk";
78
+ import { WindowMessage } from "@sanity/sdk";
52
79
 
53
80
  /**
54
81
  * @public
@@ -57,15 +84,15 @@ export declare interface AgentResourceContextOptions {
57
84
  /**
58
85
  * The project ID of the current context
59
86
  */
60
- projectId: string
87
+ projectId: string;
61
88
  /**
62
89
  * The dataset of the current context
63
90
  */
64
- dataset: string
91
+ dataset: string;
65
92
  /**
66
93
  * Optional document ID if the user is viewing/editing a specific document
67
94
  */
68
- documentId?: string
95
+ documentId?: string;
69
96
  }
70
97
 
71
98
  /**
@@ -92,7 +119,7 @@ export declare interface AgentResourceContextOptions {
92
119
  export declare function AuthBoundary({
93
120
  LoginErrorComponent,
94
121
  ...props
95
- }: AuthBoundaryProps): React.ReactNode
122
+ }: AuthBoundaryProps): React.ReactNode;
96
123
 
97
124
  /**
98
125
  * @internal
@@ -103,33 +130,33 @@ export declare interface AuthBoundaryProps {
103
130
  * Receives all props. Defaults to {@link Login}.
104
131
  */
105
132
  LoginComponent?: React.ComponentType<{
106
- header?: React.ReactNode
107
- footer?: React.ReactNode
108
- }>
133
+ header?: React.ReactNode;
134
+ footer?: React.ReactNode;
135
+ }>;
109
136
  /**
110
137
  * Custom component to render during OAuth callback processing.
111
138
  * Receives all props. Defaults to {@link LoginCallback}.
112
139
  */
113
140
  CallbackComponent?: React.ComponentType<{
114
- header?: React.ReactNode
115
- footer?: React.ReactNode
116
- }>
141
+ header?: React.ReactNode;
142
+ footer?: React.ReactNode;
143
+ }>;
117
144
  /**
118
145
  * Custom component to render when authentication errors occur.
119
146
  * Receives error boundary props and layout props. Defaults to
120
147
  * {@link LoginError}
121
148
  */
122
- LoginErrorComponent?: React.ComponentType<LoginErrorProps>
149
+ LoginErrorComponent?: React.ComponentType<LoginErrorProps>;
123
150
  /** Header content to display */
124
- header?: React.ReactNode
151
+ header?: React.ReactNode;
125
152
  /**
126
153
  * The project IDs to use for organization verification.
127
154
  */
128
- projectIds?: string[]
155
+ projectIds?: string[];
129
156
  /** Footer content to display */
130
- footer?: React.ReactNode
157
+ footer?: React.ReactNode;
131
158
  /** Protected content to render when authenticated */
132
- children?: React.ReactNode
159
+ children?: React.ReactNode;
133
160
  /**
134
161
  * Whether to verify that the project belongs to the organization specified in the dashboard context.
135
162
  * By default, organization verification is enabled when running in a dashboard context.
@@ -137,60 +164,66 @@ export declare interface AuthBoundaryProps {
137
164
  * WARNING: Disabling organization verification is NOT RECOMMENDED and may cause your application
138
165
  * to break in the future. This should never be disabled in production environments.
139
166
  */
140
- verifyOrganization?: boolean
167
+ verifyOrganization?: boolean;
141
168
  }
142
169
 
143
170
  /**
144
171
  * @public
145
172
  */
146
- export declare type ComlinkStatus = 'idle' | 'handshaking' | 'connected' | 'disconnected'
173
+ export declare type ComlinkStatus =
174
+ "idle" | "handshaking" | "connected" | "disconnected";
147
175
 
148
176
  /**
149
177
  * This provider is used to provide the Comlink token refresh feature.
150
178
  * It is used to automatically request a new token on 401 error if enabled.
151
179
  * @public
152
180
  */
153
- export declare const ComlinkTokenRefreshProvider: React_2.FC<PropsWithChildren>
154
-
155
- declare interface DashboardResource {
156
- id: string
157
- name: string
158
- title: string
159
- basePath: string
160
- projectId: string
161
- dataset: string
162
- type: string
163
- userApplicationId: string
164
- url: string
165
- }
166
-
167
- export {DatasetsResponse}
181
+ export declare const ComlinkTokenRefreshProvider: React_2.FC<PropsWithChildren>;
168
182
 
169
183
  /**
170
- * Return type for the useDispatchIntent hook
171
- * @beta
184
+ * Optional per-call overrides for {@link useCreateDocument}'s create function.
185
+ * @public
172
186
  */
173
- declare interface DispatchIntent {
174
- dispatchIntent: () => void
187
+ export declare interface CreateDocumentOverrides {
188
+ /**
189
+ * Use this document ID instead of generating one. Overrides any `documentId`
190
+ * supplied on the handle passed to `useCreateDocument`.
191
+ */
192
+ documentId?: string;
193
+ }
194
+
195
+ declare interface DashboardResource {
196
+ id: string;
197
+ name: string;
198
+ title: string;
199
+ basePath: string;
200
+ projectId: string;
201
+ dataset: string;
202
+ type: string;
203
+ userApplicationId: string;
204
+ url: string;
175
205
  }
176
206
 
207
+ export { DatasetsResponse };
208
+
177
209
  /**
178
- * SDK React DocumentHandle with optional explicit resource field.
179
- * Resource is resolved from context when not provided.
180
- * When a `resourceName` is provided, the resource will be resolved from the context using the `ResourcesContext`,
181
- * if there is a matching resource by that name.
210
+ * React SDK document handle. Adds `resourceName` to the core `DocumentHandle`.
211
+ *
212
+ * Import from `@sanity/sdk-react` (not `@sanity/sdk`) when writing option types
213
+ * for hooks — this version understands `resourceName` resolution.
214
+ *
182
215
  * @public
183
216
  */
184
217
  export declare interface DocumentHandle<
185
218
  TDocumentType extends string = string,
186
219
  TDataset extends string = string,
187
220
  TProjectId extends string = string,
188
- > extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
189
- documentId: string
221
+ > extends DocumentHandle_2<TDocumentType, TDataset, TProjectId> {
222
+ resourceName?: string;
190
223
  }
191
224
 
192
225
  declare interface DocumentInteractionHistory {
193
- recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void
226
+ recordEvent: (eventType: "viewed" | "edited" | "created" | "deleted") => void;
194
227
  }
195
228
 
196
229
  /**
@@ -205,29 +238,29 @@ export declare interface DocumentsOptions<
205
238
  TProjectId extends string = string,
206
239
  >
207
240
  extends
208
- ResourceHandle<TProjectId, TDataset>,
209
- Pick<QueryOptions<TDocumentType, TDataset, TProjectId>, 'params'> {
241
+ ResourceHandle<TDataset, TProjectId>,
242
+ Pick<QueryOptions, "perspective" | "params"> {
210
243
  /**
211
244
  * Filter documents by their `_type`. Can be a single type or an array of types.
212
245
  */
213
- documentType?: TDocumentType | TDocumentType[]
246
+ documentType?: TDocumentType | TDocumentType[];
214
247
  /**
215
248
  * GROQ filter expression to apply to the query
216
249
  */
217
- filter?: string
250
+ filter?: string;
218
251
  /**
219
252
  * Number of items to load per batch (defaults to 25)
220
253
  */
221
- batchSize?: number
254
+ batchSize?: number;
222
255
  /**
223
256
  * Sorting configuration for the results
224
257
  * @beta
225
258
  */
226
- orderings?: SortOrderingItem[]
259
+ orderings?: SortOrderingItem[];
227
260
  /**
228
261
  * Text search query to filter results
229
262
  */
230
- search?: string
263
+ search?: string;
231
264
  }
232
265
 
233
266
  /**
@@ -244,97 +277,135 @@ export declare interface DocumentsResponse<
244
277
  /**
245
278
  * Array of document handles for the current batch
246
279
  */
247
- data: DocumentHandle<TDocumentType, TDataset, TProjectId>[]
280
+ data: DocumentHandle_2<TDocumentType, TDataset, TProjectId>[];
248
281
  /**
249
282
  * Whether there are more items available to load
250
283
  */
251
- hasMore: boolean
284
+ hasMore: boolean;
252
285
  /**
253
286
  * Total count of items matching the query
254
287
  */
255
- count: number
288
+ count: number;
256
289
  /**
257
290
  * Whether a query is currently in progress
258
291
  */
259
- isPending: boolean
292
+ isPending: boolean;
260
293
  /**
261
294
  * Function to load the next batch of results
262
295
  */
263
- loadMore: () => void
296
+ loadMore: () => void;
264
297
  }
265
298
 
266
299
  /**
267
- * SDK React DocumentTypeHandle with optional explicit resource field.
268
- * Resource is resolved from context when not provided.
269
- * When a `resourceName` is provided, the resource will be resolved from the context using the `ResourcesContext`,
270
- * if there is a matching resource by that name.
300
+ * React SDK document-type handle. Adds `resourceName` to the core `DocumentTypeHandle`.
271
301
  * @public
272
302
  */
273
303
  export declare interface DocumentTypeHandle<
274
304
  TDocumentType extends string = string,
275
305
  TDataset extends string = string,
276
306
  TProjectId extends string = string,
277
- > extends ResourceHandle<TProjectId, TDataset> {
278
- documentType: TDocumentType
279
- documentId?: string
280
- liveEdit?: boolean
307
+ > extends DocumentTypeHandle_2<TDocumentType, TDataset, TProjectId> {
308
+ resourceName?: string;
281
309
  }
282
310
 
283
- /** React-layer edit document options: DocumentHandle with optional path */
284
- declare type EditDocumentOptions<TPath extends string | undefined = undefined> = DocumentHandle & {
285
- path?: TPath
311
+ /**
312
+ * The value returned by a fetcher-backed hook. The hook suspends until the
313
+ * first fetch succeeds, so `data` is always present once your component renders.
314
+ *
315
+ * @public
316
+ */
317
+ export declare interface FetcherHookResult<TData> {
318
+ /** The resolved data. Guaranteed present — the hook suspends until the first fetch succeeds. */
319
+ data: TData;
320
+ /** A fetch for this entry is in flight (background revalidation or a `refetch()`). */
321
+ isFetching: boolean;
322
+ /** The most recent background-fetch failure while data still renders; cleared by the next success. */
323
+ error: unknown;
324
+ /** Imperatively refetch, bypassing staleness. Resolves with the refreshed data. */
325
+ refetch: () => Promise<TData>;
286
326
  }
287
327
 
288
328
  /**
289
329
  * @internal
290
330
  */
291
331
  export declare interface FrameConnection<TFrameMessage extends FrameMessage> {
292
- connect: (frameWindow: Window) => () => void
293
- sendMessage: <T extends TFrameMessage['type']>(
332
+ connect: (frameWindow: Window) => () => void;
333
+ sendMessage: <T extends TFrameMessage["type"]>(
294
334
  ...params: Extract<
295
335
  TFrameMessage,
296
336
  {
297
- type: T
337
+ type: T;
298
338
  }
299
- >['data'] extends undefined
339
+ >["data"] extends undefined
300
340
  ? [type: T]
301
341
  : [
302
342
  type: T,
303
343
  data: Extract<
304
344
  TFrameMessage,
305
345
  {
306
- type: T
346
+ type: T;
307
347
  }
308
- >['data'],
348
+ >["data"],
309
349
  ]
310
- ) => void
350
+ ) => void;
311
351
  }
312
352
 
353
+ declare type IgnoredKey =
354
+ "_id" | "_type" | "_rev" | "_createdAt" | "_updatedAt";
355
+
313
356
  /**
314
357
  * @alpha
315
358
  */
316
- declare type LoginErrorProps = FallbackProps
359
+ declare type LoginErrorProps = FallbackProps;
317
360
 
318
361
  declare interface ManageFavorite extends FavoriteStatusResponse {
319
- favorite: () => Promise<void>
320
- unfavorite: () => Promise<void>
321
- isFavorited: boolean
362
+ favorite: () => Promise<void>;
363
+ unfavorite: () => Promise<void>;
364
+ isFavorited: boolean;
322
365
  }
323
366
 
324
367
  /**
325
368
  * @public
326
369
  */
327
- declare type MessageData = Record<string, unknown> | undefined
370
+ declare type MessageData = Record<string, unknown> | undefined;
328
371
 
329
372
  /**
330
373
  * @internal
331
374
  */
332
375
  export declare type MessageHandler<TWindowMessage extends WindowMessage> = (
333
- event: TWindowMessage['data'],
334
- ) => TWindowMessage['response'] | Promise<TWindowMessage['response']>
376
+ event: TWindowMessage["data"],
377
+ ) => TWindowMessage["response"] | Promise<TWindowMessage["response"]>;
335
378
 
336
- declare interface NamedResources {
337
- [key: string]: DocumentResource
379
+ /**
380
+ * The value returned by a mutation-backed hook. The write-side counterpart to
381
+ * {@link FetcherHookResult}: local `{mutate, isPending, error, data, reset}`
382
+ * state around a core mutation action.
383
+ *
384
+ * @public
385
+ */
386
+ export declare interface MutationHookResult<TInput, TResult> {
387
+ /**
388
+ * Runs the mutation. Resolves with the server response; rejects on failure
389
+ * (the failure is also captured in {@link MutationHookResult.error}, so a
390
+ * fire-and-forget caller should read `error` and an `await`ing caller should
391
+ * `try`/`catch`).
392
+ */
393
+ mutate: (input: TInput) => Promise<TResult>;
394
+ /** A mutation is currently in flight. */
395
+ isPending: boolean;
396
+ /** The most recent failure; cleared by the next `mutate` or `reset`. */
397
+ error: unknown;
398
+ /** The last successful server response, or `undefined` before the first success. */
399
+ data: TResult | undefined;
400
+ /** Clears state back to idle and abandons any in-flight result. */
401
+ reset: () => void;
402
+ }
403
+
404
+ /** In-flight CLI PR is using named sources since it's aspirational.
405
+ * We can transform the shape in this function until it's finalized.
406
+ */
407
+ declare interface NamedSources {
408
+ [key: string]: SanityConfig;
338
409
  }
339
410
 
340
411
  /**
@@ -342,13 +413,13 @@ declare interface NamedResources {
342
413
  * @category Types
343
414
  */
344
415
  export declare interface NavigateToStudioResult {
345
- navigateToStudioDocument: () => void
416
+ navigateToStudioDocument: () => void;
346
417
  }
347
418
 
348
419
  declare interface Observer<T> {
349
- next?: (value: T) => void
350
- error?: (err: unknown) => void
351
- complete?: () => void
420
+ next?: (value: T) => void;
421
+ error?: (err: unknown) => void;
422
+ complete?: () => void;
352
423
  }
353
424
 
354
425
  /**
@@ -361,28 +432,27 @@ export declare interface PaginatedDocumentsOptions<
361
432
  TDocumentType extends string = string,
362
433
  TDataset extends string = string,
363
434
  TProjectId extends string = string,
364
- >
365
- extends
366
- ResourceHandle<TProjectId, TDataset>,
367
- Pick<QueryOptions<TDocumentType, TDataset, TProjectId>, 'params'> {
368
- documentType?: TDocumentType | TDocumentType[]
435
+ > extends WithResourceNameSupport<
436
+ Omit<QueryOptions<TDocumentType, TDataset, TProjectId>, "query">
437
+ > {
438
+ documentType?: TDocumentType | TDocumentType[];
369
439
  /**
370
440
  * GROQ filter expression to apply to the query
371
441
  */
372
- filter?: string
442
+ filter?: string;
373
443
  /**
374
444
  * Number of items to display per page (defaults to 25)
375
445
  */
376
- pageSize?: number
446
+ pageSize?: number;
377
447
  /**
378
448
  * Sorting configuration for the results
379
449
  * @beta
380
450
  */
381
- orderings?: SortOrderingItem[]
451
+ orderings?: SortOrderingItem[];
382
452
  /**
383
453
  * Text search query to filter results
384
454
  */
385
- search?: string
455
+ search?: string;
386
456
  }
387
457
 
388
458
  /**
@@ -399,116 +469,120 @@ export declare interface PaginatedDocumentsResponse<
399
469
  /**
400
470
  * Array of document handles for the current page
401
471
  */
402
- data: DocumentHandle<TDocumentType, TDataset, TProjectId>[]
472
+ data: DocumentHandle_2<TDocumentType, TDataset, TProjectId>[];
403
473
  /**
404
474
  * Whether a query is currently in progress
405
475
  */
406
- isPending: boolean
476
+ isPending: boolean;
407
477
  /**
408
478
  * Number of items displayed per page
409
479
  */
410
- pageSize: number
480
+ pageSize: number;
411
481
  /**
412
482
  * Current page number (1-indexed)
413
483
  */
414
- currentPage: number
484
+ currentPage: number;
415
485
  /**
416
486
  * Total number of pages available
417
487
  */
418
- totalPages: number
488
+ totalPages: number;
419
489
  /**
420
490
  * Starting index of the current page (0-indexed)
421
491
  */
422
- startIndex: number
492
+ startIndex: number;
423
493
  /**
424
494
  * Ending index of the current page (exclusive, 0-indexed)
425
495
  */
426
- endIndex: number
496
+ endIndex: number;
427
497
  /**
428
498
  * Total count of items matching the query
429
499
  */
430
- count: number
500
+ count: number;
431
501
  /**
432
502
  * Navigate to the first page
433
503
  */
434
- firstPage: () => void
504
+ firstPage: () => void;
435
505
  /**
436
506
  * Whether there is a first page available to navigate to
437
507
  */
438
- hasFirstPage: boolean
508
+ hasFirstPage: boolean;
439
509
  /**
440
510
  * Navigate to the previous page
441
511
  */
442
- previousPage: () => void
512
+ previousPage: () => void;
443
513
  /**
444
514
  * Whether there is a previous page available to navigate to
445
515
  */
446
- hasPreviousPage: boolean
516
+ hasPreviousPage: boolean;
447
517
  /**
448
518
  * Navigate to the next page
449
519
  */
450
- nextPage: () => void
520
+ nextPage: () => void;
451
521
  /**
452
522
  * Whether there is a next page available to navigate to
453
523
  */
454
- hasNextPage: boolean
524
+ hasNextPage: boolean;
455
525
  /**
456
526
  * Navigate to the last page
457
527
  */
458
- lastPage: () => void
528
+ lastPage: () => void;
459
529
  /**
460
530
  * Whether there is a last page available to navigate to
461
531
  */
462
- hasLastPage: boolean
532
+ hasLastPage: boolean;
463
533
  /**
464
534
  * Navigate to a specific page number
465
535
  * @param pageNumber - The page number to navigate to (1-indexed)
466
536
  */
467
- goToPage: (pageNumber: number) => void
537
+ goToPage: (pageNumber: number) => void;
468
538
  }
469
539
 
470
540
  /**
471
541
  * @public
472
542
  * @category Types
473
543
  * @interface
544
+ * @deprecated use the Project type directly.
474
545
  */
475
- export declare type ProjectWithoutMembers = Omit<SanityProject_2, 'members'>
546
+ export declare type ProjectWithoutMembers = Project;
476
547
 
477
548
  /**
478
549
  * This version is provided by pkg-utils at build time
479
550
  * @internal
480
551
  */
481
- export declare const REACT_SDK_VERSION: {}
482
-
483
- /** Options for useQuery: QueryOptions with resource made optional (resolved from context) */
484
- declare type ReactQueryOptions = Omit<QueryOptions, 'resource' | 'resourceName'> & ResourceHandle
552
+ export declare const REACT_SDK_VERSION: {};
485
553
 
486
554
  /** @internal */
487
555
  export declare function renderSanityApp(
488
556
  rootElement: HTMLElement | null,
489
- namedResources: NamedResources,
557
+ namedSources: NamedSources,
490
558
  options: RenderSanitySDKAppOptions,
491
559
  children: React.ReactNode,
492
- ): () => void
560
+ ): () => void;
493
561
 
494
562
  declare interface RenderSanitySDKAppOptions {
495
- reactStrictMode?: boolean
563
+ reactStrictMode?: boolean;
496
564
  }
497
565
 
498
566
  /**
499
- * SDK React ResourceHandle with optional explicit resource field.
500
- * Resource is resolved from context when not provided.
501
- * When a `resourceName` is provided, the resource will be resolved from the context using the `ResourcesContext`,
502
- * if there is a matching resource by that name.
567
+ * React SDK resource handle — extends the core DatasetHandle with `resourceName`
568
+ * for context-based resource resolution.
569
+ *
570
+ * Use this (or its subtypes) as the options type for custom hooks that need to
571
+ * accept a resource. It accepts a `resource` object, a `resourceName` registered
572
+ * via the `resources` prop on `<SanityApp>`, or a bare `projectId`/`dataset` pair
573
+ * for backward compatibility.
574
+ *
503
575
  * @public
504
576
  */
505
577
  export declare interface ResourceHandle<
506
- TProjectId extends string = string,
507
578
  TDataset extends string = string,
508
- > {
509
- resource?: DocumentResource<TProjectId, TDataset>
510
- resourceName?: string
511
- perspective?: PerspectiveHandle['perspective']
579
+ TProjectId extends string = string,
580
+ > extends DatasetHandle<TDataset, TProjectId> {
581
+ /**
582
+ * Name of a resource registered via the `resources` prop on `<SanityApp>`.
583
+ * Resolved to a `DocumentResource` at the React layer.
584
+ */
585
+ resourceName?: string;
512
586
  }
513
587
 
514
588
  /**
@@ -516,14 +590,7 @@ export declare interface ResourceHandle<
516
590
  *
517
591
  * @internal
518
592
  *
519
- * @remarks
520
- * - **Root usage** (no parent instance): creates a `SanityInstance` with the
521
- * given config and provides it via `SanityInstanceContext`.
522
- * - **Nested usage** (inside an existing provider): sets
523
- * `ResourceContext` and `PerspectiveContext` so hooks in the subtree
524
- * resolve the correct resource/perspective without creating a new instance.
525
- *
526
- * @example Root provider
593
+ * @example
527
594
  * ```tsx
528
595
  * <ResourceProvider
529
596
  * resource={{ projectId: 'your-project-id', dataset: 'production' }}
@@ -532,46 +599,31 @@ export declare interface ResourceHandle<
532
599
  * <YourApp />
533
600
  * </ResourceProvider>
534
601
  * ```
535
- *
536
- * @example Nested override
537
- * ```tsx
538
- * <ResourceProvider
539
- * resource={{ projectId: 'other-project', dataset: 'staging' }}
540
- * fallback={<LoadingSpinner />}
541
- * >
542
- * <SubSection />
543
- * </ResourceProvider>
544
- * ```
545
602
  */
546
603
  export declare function ResourceProvider({
547
604
  children,
548
605
  fallback,
549
606
  resource,
550
- ...rest
551
- }: ResourceProviderProps): React.ReactNode
607
+ ...config
608
+ }: ResourceProviderProps): React.ReactNode;
552
609
 
553
610
  /**
554
- * Props for the ResourceProvider component.
555
- *
556
- * Extends `SanityConfig` (minus `defaultResource`) so new config fields are
557
- * automatically forwarded. The `resource` prop replaces `defaultResource`
558
- * with a name that better describes its role at the React layer.
559
- *
611
+ * Props for the ResourceProvider component
560
612
  * @internal
561
613
  */
562
- export declare interface ResourceProviderProps extends Omit<SanityConfig, 'defaultResource'> {
614
+ export declare interface ResourceProviderProps extends SanityConfig {
563
615
  /**
564
616
  * The document resource (project/dataset, media library, or canvas)
565
617
  * for this subtree. Hooks that don't specify an explicit resource will
566
618
  * use this value.
567
619
  */
568
- resource?: DocumentResource
620
+ resource?: DocumentResource;
569
621
  /**
570
622
  * React node to show while content is loading.
571
623
  * Used as the fallback for the internal Suspense boundary.
572
624
  */
573
- fallback: React.ReactNode
574
- children: React.ReactNode
625
+ fallback: React.ReactNode;
626
+ children: React.ReactNode;
575
627
  }
576
628
 
577
629
  /**
@@ -581,49 +633,57 @@ export declare interface ResourceProviderProps extends Omit<SanityConfig, 'defau
581
633
  * as well as application context and state which is used by the Sanity React hooks. Your application
582
634
  * must be wrapped with the SanityApp component to function properly.
583
635
  *
584
- * The `config` prop accepts a {@link SanityConfig} object. Use the `resources` prop to declare
585
- * one or more named data resources for your app.
636
+ * The `config` prop on the SanityApp component accepts either a single {@link SanityConfig} object, or an array of them.
637
+ * This allows your app to work with one or more of your organization's datasets.
638
+ *
639
+ * When rendered inside a Sanity Studio that provides `SDKStudioContext`, the `config` prop is
640
+ * optional — `SanityApp` will automatically derive `projectId`, `dataset`, and auth from the
641
+ * Studio workspace.
586
642
  *
587
- * When rendered inside a Sanity Studio that provides `SDKStudioContext`, the `config` and `resources`
588
- * props are optional — `SanityApp` will automatically derive them from the Studio workspace.
643
+ * @remarks
644
+ * When passing multiple SanityConfig objects to the `config` prop, the first configuration in the array becomes the default
645
+ * configuration used by the App SDK Hooks.
589
646
  *
590
- * When both `config` and `SDKStudioContext` are available, the explicit props take precedence.
647
+ * When both `config` and `SDKStudioContext` are available, the explicit `config` takes precedence.
591
648
  *
592
649
  * @category Components
593
650
  * @param props - Your Sanity configuration and the React children to render
594
651
  * @returns Your Sanity application, integrated with your Sanity configuration and application context
595
652
  *
596
- * @example Single project
653
+ * @example
597
654
  * ```tsx
598
- * import { SanityApp } from '@sanity/sdk-react'
655
+ * import { SanityApp, type SanityConfig } from '@sanity/sdk-react'
599
656
  *
600
- * export default function MyApp() {
601
- * return (
602
- * <SanityApp
603
- * resources={{
604
- * default: { projectId: 'my-project-id', dataset: 'production' },
605
- * }}
606
- * fallback={<div>Loading…</div>}
607
- * >
608
- * <MyAppRoot />
609
- * </SanityApp>
610
- * )
657
+ * import MyAppRoot from './Root'
658
+ *
659
+ * // Single project configuration
660
+ * const mySanityConfig: SanityConfig = {
661
+ * projectId: 'my-project-id',
662
+ * dataset: 'production',
611
663
  * }
612
- * ```
613
664
  *
614
- * @example Multiple resources
615
- * ```tsx
616
- * import { SanityApp } from '@sanity/sdk-react'
665
+ * // Or multiple project configurations
666
+ * const multipleConfigs: SanityConfig[] = [
667
+ * // Configuration for your main project. This will be used as the default project for hooks.
668
+ * {
669
+ * projectId: 'marketing-website-project',
670
+ * dataset: 'production',
671
+ * },
672
+ * // Configuration for a separate blog project
673
+ * {
674
+ * projectId: 'blog-project',
675
+ * dataset: 'production',
676
+ * },
677
+ * // Configuration for a separate ecommerce project
678
+ * {
679
+ * projectId: 'ecommerce-project',
680
+ * dataset: 'production',
681
+ * }
682
+ * ]
617
683
  *
618
684
  * export default function MyApp() {
619
685
  * return (
620
- * <SanityApp
621
- * resources={{
622
- * default: { projectId: 'abc123', dataset: 'production' },
623
- * 'blog-project': { projectId: 'def456', dataset: 'production' },
624
- * }}
625
- * fallback={<div>Loading…</div>}
626
- * >
686
+ * <SanityApp config={mySanityConfig} fallback={<div>Loading…</div>}>
627
687
  * <MyAppRoot />
628
688
  * </SanityApp>
629
689
  * )
@@ -634,9 +694,8 @@ export declare function SanityApp({
634
694
  children,
635
695
  fallback,
636
696
  config: configProp,
637
- resources: resourcesProp,
638
697
  ...props
639
- }: SanityAppProps): ReactElement
698
+ }: SanityAppProps): ReactElement;
640
699
 
641
700
  /**
642
701
  * @public
@@ -644,54 +703,136 @@ export declare function SanityApp({
644
703
  */
645
704
  export declare interface SanityAppProps {
646
705
  /**
647
- * Core configuration for the SDK instance (auth, studio, perspective).
648
- * Optional when `SanityApp` is rendered inside an `SDKStudioContext`
649
- * provider (e.g. inside Sanity Studio) — the config is derived from
650
- * the workspace automatically.
706
+ * One or more SanityConfig objects providing a project ID and dataset name.
707
+ * Optional when `SanityApp` is rendered inside an `SDKStudioContext` provider
708
+ * (e.g. inside Sanity Studio) — the config is derived from the workspace
709
+ * automatically.
651
710
  */
652
- config?: SanityConfig
711
+ config?: SanityConfig | SanityConfig[];
712
+ /** @deprecated use the `config` prop instead. */
713
+ sanityConfigs?: SanityConfig[];
714
+ resources?: Record<string, DocumentResource>;
715
+ children: React.ReactNode;
716
+ fallback: React.ReactNode;
653
717
  /**
654
- * Named document resources for the application. The resource keyed `"default"`
655
- * is used automatically when no explicit resource is specified in hooks.
718
+ * Set this to automatically fetch and register the organization's media library and canvas as named resources.
719
+ * These resources will be available to hooks as `media-library` and `canvas`.
720
+ *
721
+ * The SDK App must be running in the organization's Dashboard to use this feature.
722
+ *
723
+ * @example
724
+ * ```tsx
725
+ *
726
+ * const MyApp = () => {
727
+ * // should "just work" because of inferMediaLibraryAndCanvas.
728
+ * const {data: assets} = useDocuments({
729
+ * documentType: 'sanity.asset',
730
+ * resourceName: 'media-library',
731
+ * })
732
+ * return (
733
+ * <div>
734
+ * {assets.map((asset) => (
735
+ * <div key={asset._id}>{asset.originalFilename}</div>
736
+ * ))}
737
+ * </div>
738
+ * )
739
+ * }
740
+ * <SanityApp inferMediaLibraryAndCanvas>
741
+ * <MyApp />
742
+ * </SanityApp>
743
+ * ```
656
744
  */
657
- resources?: Record<string, DocumentResource>
658
- children: React.ReactNode
659
- fallback: React.ReactNode
745
+ inferMediaLibraryAndCanvas?: boolean;
660
746
  }
661
747
 
662
- export {SanityDocument}
748
+ export { SanityDocument };
663
749
 
664
- export {SanityProjectMember}
750
+ /**
751
+ * Provides an externally-created Sanity instance to child components through React Context.
752
+ *
753
+ * @internal
754
+ *
755
+ * @remarks
756
+ * Unlike {@link ResourceProvider}, this component does not create or dispose a SanityInstance.
757
+ * The caller is responsible for creating the instance via `createSanityInstance` and disposing
758
+ * it when appropriate. This is useful when a non-React system layer (e.g. a state machine)
759
+ * owns the instance and the React tree should consume it without managing its lifecycle.
760
+ *
761
+ * All SDK hooks (`useSanityInstance`, `useDocuments`, etc.) will read from the provided instance.
762
+ *
763
+ * @example Providing a pre-created instance
764
+ * ```tsx
765
+ * import { createSanityInstance, type SanityConfig } from '@sanity/sdk'
766
+ * import { SanityInstanceProvider } from '@sanity/sdk-react'
767
+ *
768
+ * const config: SanityConfig = {
769
+ * projectId: 'my-project-id',
770
+ * dataset: 'production',
771
+ * }
772
+ *
773
+ * const instance = createSanityInstance(config)
774
+ *
775
+ * function App() {
776
+ * return (
777
+ * <SanityInstanceProvider instance={instance} fallback={<div>Loading...</div>}>
778
+ * <MyApp />
779
+ * </SanityInstanceProvider>
780
+ * )
781
+ * }
782
+ * ```
783
+ *
784
+ * @category Components
785
+ */
786
+ export declare function SanityInstanceProvider({
787
+ instance,
788
+ fallback,
789
+ children,
790
+ }: SanityInstanceProviderProps): React.ReactNode;
791
+
792
+ /**
793
+ * Props for the SanityInstanceProvider component
794
+ * @public
795
+ */
796
+ export declare interface SanityInstanceProviderProps {
797
+ /**
798
+ * A pre-created SanityInstance to provide to child components.
799
+ * The caller owns the instance lifecycle — SanityInstanceProvider
800
+ * will not dispose it on unmount.
801
+ */
802
+ instance: SanityInstance;
803
+ /**
804
+ * React node to show while content is loading.
805
+ * Used as the fallback for the internal Suspense boundary.
806
+ */
807
+ fallback: React.ReactNode;
808
+ children: React.ReactNode;
809
+ }
810
+
811
+ export { SanityProjectMember };
665
812
 
666
813
  /**
667
814
  * @internal
668
815
  *
669
816
  * Top-level context provider that provides access to the Sanity SDK.
670
- *
671
- * Creates a single `ResourceProvider` (and therefore a single `SanityInstance`)
672
- * for the given config. Resource resolution is handled by `ResourcesContext`
673
- * and the `"default"` named resource.
674
817
  */
675
818
  export declare function SDKProvider({
676
819
  children,
677
820
  config,
678
- resources,
679
821
  fallback,
822
+ inferMediaLibraryAndCanvas,
680
823
  ...props
681
- }: SDKProviderProps): ReactElement
824
+ }: SDKProviderProps): ReactElement;
682
825
 
683
826
  /**
684
827
  * @internal
685
828
  */
686
829
  export declare interface SDKProviderProps extends AuthBoundaryProps {
687
- children: ReactNode
688
- config: SanityConfig
689
- /**
690
- * Named document resources map. Provided to `ResourcesContext` for
691
- * name-based resource resolution in hooks.
692
- */
693
- resources?: Record<string, DocumentResource>
694
- fallback: ReactNode
830
+ children: ReactNode;
831
+ config: SanityConfig | SanityConfig[];
832
+ fallback: ReactNode;
833
+ resources?: Record<string, DocumentResource>;
834
+ /** When set, automatically fetches and registers the organization's media library and canvas as named resources. */
835
+ inferMediaLibraryAndCanvas?: boolean;
695
836
  }
696
837
 
697
838
  /**
@@ -728,15 +869,9 @@ export declare interface SDKProviderProps extends AuthBoundaryProps {
728
869
  *
729
870
  * @public
730
871
  */
731
- export declare const SDKStudioContext: Context<StudioWorkspaceHandle | null>
732
-
733
- export {SortOrderingItem}
872
+ export declare const SDKStudioContext: Context<StudioWorkspaceHandle | null>;
734
873
 
735
- export {StrictDocumentHandle}
736
-
737
- export {StrictDocumentTypeHandle}
738
-
739
- export {StrictResourceHandle}
874
+ export { SortOrderingItem };
740
875
 
741
876
  /**
742
877
  * Minimal duck-typed interface representing a Sanity Studio workspace.
@@ -747,15 +882,15 @@ export {StrictResourceHandle}
747
882
  */
748
883
  export declare interface StudioWorkspaceHandle {
749
884
  /** The Sanity project ID for this workspace. */
750
- projectId: string
885
+ projectId: string;
751
886
  /** The dataset name for this workspace. */
752
- dataset: string
887
+ dataset: string;
753
888
  /**
754
889
  * Whether the Studio has determined the user is authenticated.
755
890
  * When `true` and the token source emits `null`, the SDK infers
756
891
  * cookie-based auth is in use and skips the logged-out state.
757
892
  */
758
- authenticated?: boolean
893
+ authenticated?: boolean;
759
894
  /** Authentication state for this workspace. */
760
895
  auth: {
761
896
  /**
@@ -766,38 +901,39 @@ export declare interface StudioWorkspaceHandle {
766
901
  * Optional because Studios before Aug 2022 may not expose it. When
767
902
  * absent, the SDK falls back to localStorage/cookie discovery.
768
903
  */
769
- token?: TokenSource
770
- }
904
+ token?: TokenSource;
905
+ };
771
906
  }
772
907
 
773
908
  declare interface StudioWorkspacesResult {
774
- workspacesByProjectIdAndDataset: WorkspacesByProjectIdDataset
775
- error: string | null
909
+ workspacesByProjectIdAndDataset: WorkspacesByProjectIdDataset;
910
+ error: string | null;
776
911
  }
777
912
 
778
913
  declare interface Subscribable<T> {
779
- subscribe(observer: Observer<T>): Subscription
914
+ subscribe(observer: Observer<T>): Subscription;
780
915
  subscribe(
781
916
  next: (value: T) => void,
782
917
  error?: (err: unknown) => void,
783
918
  complete?: () => void,
784
- ): Subscription
919
+ ): Subscription;
785
920
  }
786
921
 
787
922
  declare interface Subscription {
788
- unsubscribe(): void
923
+ unsubscribe(): void;
789
924
  }
790
925
 
791
- declare type Updater<TValue> = TValue | ((currentValue: TValue) => TValue)
926
+ declare type Updater<TValue> = TValue | ((currentValue: TValue) => TValue);
792
927
 
793
928
  /**
794
929
  * @public
795
-
930
+ * @function
931
+ *
796
932
  * Returns the active releases for the current project,
797
933
  * represented as a list of release documents.
798
934
  *
799
935
  * @returns The active releases for the current project.
800
- * @category Projects
936
+ * @category Releases
801
937
  * @example
802
938
  * ```tsx
803
939
  * import {useActiveReleases} from '@sanity/sdk-react'
@@ -805,15 +941,9 @@ declare type Updater<TValue> = TValue | ((currentValue: TValue) => TValue)
805
941
  * const activeReleases = useActiveReleases()
806
942
  * ```
807
943
  */
808
- declare type UseActiveReleases = {
809
- (options?: ResourceHandle | undefined): ReleaseDocument[]
810
- }
811
-
812
- /**
813
- * @public
814
- * @function
815
- */
816
- export declare const useActiveReleases: UseActiveReleases
944
+ export declare function useActiveReleases(
945
+ options?: WithResourceNameSupport<SanityConfig> | undefined,
946
+ ): ReleaseDocument[];
817
947
 
818
948
  /**
819
949
  * @alpha
@@ -882,9 +1012,9 @@ export declare const useActiveReleases: UseActiveReleases
882
1012
  *
883
1013
  * @category Agent Actions
884
1014
  */
885
- export declare function useAgentGenerate(): (
886
- options: AgentGenerateOptions & WithResourceNameSupport<AgentResourceOptions>,
887
- ) => Subscribable<unknown>
1015
+ export declare function useAgentGenerate(
1016
+ resourceHandle?: ResourceHandle,
1017
+ ): (options: AgentGenerateOptions) => Subscribable<unknown>;
888
1018
 
889
1019
  /**
890
1020
  * @alpha
@@ -1035,9 +1165,9 @@ export declare function useAgentGenerate(): (
1035
1165
  *
1036
1166
  * @category Agent Actions
1037
1167
  */
1038
- export declare function useAgentPatch(): (
1039
- options: AgentPatchOptions & WithResourceNameSupport<AgentResourceOptions>,
1040
- ) => Promise<AgentPatchResult>
1168
+ export declare function useAgentPatch(
1169
+ resourceHandle?: ResourceHandle,
1170
+ ): (options: AgentPatchOptions) => Promise<AgentPatchResult>;
1041
1171
 
1042
1172
  /**
1043
1173
  * @alpha
@@ -1133,9 +1263,9 @@ export declare function useAgentPatch(): (
1133
1263
  *
1134
1264
  * @category Agent Actions
1135
1265
  */
1136
- export declare function useAgentPrompt(): (
1137
- options: AgentPromptOptions & WithResourceNameSupport<AgentResourceOptions>,
1138
- ) => Promise<AgentPromptResult>
1266
+ export declare function useAgentPrompt(
1267
+ resourceHandle?: ResourceHandle,
1268
+ ): (options: AgentPromptOptions) => Promise<AgentPromptResult>;
1139
1269
 
1140
1270
  /**
1141
1271
  * @public
@@ -1167,7 +1297,9 @@ export declare function useAgentPrompt(): (
1167
1297
  * }
1168
1298
  * ```
1169
1299
  */
1170
- export declare function useAgentResourceContext(options: AgentResourceContextOptions): void
1300
+ export declare function useAgentResourceContext(
1301
+ options: AgentResourceContextOptions,
1302
+ ): void;
1171
1303
 
1172
1304
  /**
1173
1305
  * @alpha
@@ -1240,9 +1372,9 @@ export declare function useAgentResourceContext(options: AgentResourceContextOpt
1240
1372
  *
1241
1373
  * @category Agent Actions
1242
1374
  */
1243
- export declare function useAgentTransform(): (
1244
- options: AgentTransformOptions & WithResourceNameSupport<AgentResourceOptions>,
1245
- ) => Subscribable<unknown>
1375
+ export declare function useAgentTransform(
1376
+ resourceHandle?: ResourceHandle,
1377
+ ): (options: AgentTransformOptions) => Subscribable<unknown>;
1246
1378
 
1247
1379
  /**
1248
1380
  * @alpha
@@ -1334,9 +1466,76 @@ export declare function useAgentTransform(): (
1334
1466
  *
1335
1467
  * @category Agent Actions
1336
1468
  */
1337
- export declare function useAgentTranslate(): (
1338
- options: AgentTranslateOptions & WithResourceNameSupport<AgentResourceOptions>,
1339
- ) => Subscribable<unknown>
1469
+ export declare function useAgentTranslate(
1470
+ resourceHandle?: ResourceHandle,
1471
+ ): (options: AgentTranslateOptions) => Subscribable<unknown>;
1472
+
1473
+ /**
1474
+ * @public
1475
+ * @function
1476
+ *
1477
+ * Returns every release the dataset has — including `archived`, `published`,
1478
+ * and mid-transition states (`archiving`, `unarchiving`, `publishing`,
1479
+ * `scheduling`).
1480
+ *
1481
+ * Use this hook when you're building a release-management UI (listing
1482
+ * releases, surfacing lifecycle controls, etc.) so a release stays visible
1483
+ * across its full lifecycle — including after it's been published or
1484
+ * archived. For perspective / content queries, prefer
1485
+ * {@link useActiveReleases}, which filters to releases that still affect
1486
+ * what's queryable.
1487
+ *
1488
+ * @returns Every release for the current project, sorted to match the order
1489
+ * used by {@link useActiveReleases}.
1490
+ * @category Releases
1491
+ * @example
1492
+ * ```tsx
1493
+ * import {useAllReleases} from '@sanity/sdk-react'
1494
+ *
1495
+ * const releases = useAllReleases()
1496
+ * ```
1497
+ */
1498
+ export declare function useAllReleases(
1499
+ options?: WithResourceNameSupport<SanityConfig> | undefined,
1500
+ ): ReleaseDocument[];
1501
+
1502
+ /**
1503
+ * Returns a single application by id.
1504
+ *
1505
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
1506
+ * The `include` tokens you pass shape `data`: each requested token adds its
1507
+ * field, and omitted ones are absent from the type.
1508
+ *
1509
+ * @public
1510
+ * @param applicationId - The application id.
1511
+ * @param options - Optional `include` list to expand related resources.
1512
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
1513
+ */
1514
+ export declare const useApplication: <
1515
+ Include extends ApplicationInclude = never,
1516
+ >(
1517
+ applicationId: string,
1518
+ options?: {
1519
+ include?: Include[];
1520
+ },
1521
+ ) => FetcherHookResult<Application<Include>>;
1522
+
1523
+ /**
1524
+ * Returns the applications matching the given options.
1525
+ *
1526
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
1527
+ * The `include` tokens you pass shape `data.data`: each requested token adds its
1528
+ * field, and omitted ones are absent from the type.
1529
+ *
1530
+ * @public
1531
+ * @param options - Filter and include options for the applications list.
1532
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
1533
+ */
1534
+ export declare const useApplications: <
1535
+ Include extends ApplicationInclude = never,
1536
+ >(
1537
+ options: ApplicationsOptions<Include>,
1538
+ ) => FetcherHookResult<ApplicationsResponse<Include>>;
1340
1539
 
1341
1540
  /**
1342
1541
  * @public
@@ -1351,7 +1550,9 @@ declare interface UseApplyDocumentActions {
1351
1550
  | DocumentAction<TDocumentType, TDataset, TProjectId>
1352
1551
  | DocumentAction<TDocumentType, TDataset, TProjectId>[],
1353
1552
  options?: ResourceHandle,
1354
- ) => Promise<ActionsResult>
1553
+ ) => Promise<
1554
+ ActionsResult<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>>
1555
+ >;
1355
1556
  }
1356
1557
 
1357
1558
  /**
@@ -1476,8 +1677,147 @@ declare interface UseApplyDocumentActions {
1476
1677
  * return <button onClick={handleCreateArticle}>Create Article</button>
1477
1678
  * }
1478
1679
  * ```
1680
+ *
1681
+ * @example Create a new document in a release
1682
+ * ```tsx
1683
+ * import {
1684
+ * createDocument,
1685
+ * createDocumentHandle,
1686
+ * useApplyDocumentActions
1687
+ * } from '@sanity/sdk-react'
1688
+ *
1689
+ * function CreateArticleButton() {
1690
+ * const apply = useApplyDocumentActions()
1691
+ *
1692
+ * const handleCreateArticle = () => {
1693
+ * // Use any valid document ID — not the internal `versions.<releaseName>.<id>` format or "drafts.<id>" format.
1694
+ * // New documents must be explicitly created with `createDocument` to become part of a release.
1695
+ * const newDocHandle = createDocumentHandle({
1696
+ * documentId: crypto.randomUUID(), // or the existing document ID you want to make a release version of
1697
+ * documentType: 'article',
1698
+ * perspective: {releaseName: 'summer-drop'},
1699
+ * })
1700
+ *
1701
+ * apply(
1702
+ * createDocument(newDocHandle, {
1703
+ * title: 'New Article',
1704
+ * author: 'John Doe',
1705
+ * publishedAt: new Date().toISOString(),
1706
+ * })
1707
+ * )
1708
+ * }
1709
+ *
1710
+ * return <button onClick={handleCreateArticle}>Create Article</button>
1711
+ * }
1712
+ * ```
1713
+ *
1714
+ * @example Edit an existing document in a release
1715
+ * ```tsx
1716
+ * import {
1717
+ * editDocument,
1718
+ * createDocumentHandle,
1719
+ * useApplyDocumentActions
1720
+ * } from '@sanity/sdk-react'
1721
+ *
1722
+ * function EditArticleInReleaseButton({documentId}: {documentId: string}) {
1723
+ * const apply = useApplyDocumentActions()
1724
+ *
1725
+ * const handleEdit = () => {
1726
+ * // Pass the document's regular ID — not `versions.<releaseName>.<id>`.
1727
+ * // Documents that already have a version in the release can be edited directly with `editDocument`.
1728
+ * const docHandle = createDocumentHandle({
1729
+ * documentId,
1730
+ * documentType: 'article',
1731
+ * perspective: {releaseName: 'summer-drop'},
1732
+ * })
1733
+ *
1734
+ * apply(editDocument(docHandle, {title: 'Updated for release'}))
1735
+ * }
1736
+ *
1737
+ * return <button onClick={handleEdit}>Edit in Release</button>
1738
+ * }
1739
+ * ```
1740
+ */
1741
+ export declare const useApplyDocumentActions: UseApplyDocumentActions;
1742
+
1743
+ /**
1744
+ * @public
1479
1745
  */
1480
- export declare const useApplyDocumentActions: UseApplyDocumentActions
1746
+ declare interface UseApplyReleaseActions {
1747
+ (): (
1748
+ action: ReleaseAction | ReleaseAction[],
1749
+ options?: ResourceHandle,
1750
+ ) => Promise<ActionsResult>;
1751
+ }
1752
+
1753
+ /**
1754
+ * @public
1755
+ *
1756
+ * Provides a stable callback function for applying one or more release actions.
1757
+ *
1758
+ * This hook wraps the core `applyDocumentActions` functionality from `@sanity/sdk`,
1759
+ * integrating it with the React component lifecycle and {@link SanityInstance}.
1760
+ * It accepts release-lifecycle actions generated by {@link createRelease},
1761
+ * {@link editRelease}, {@link publishRelease}, {@link scheduleRelease},
1762
+ * {@link unscheduleRelease}, {@link archiveRelease}, {@link unarchiveRelease},
1763
+ * and {@link deleteRelease}.
1764
+ *
1765
+ * Note that actions submitted via this hook will cascade to the documents in the release.
1766
+ * For example, if you create a release and then publish it, the documents in the release will be published.
1767
+ * If you delete a published release, the version documents will be deleted.
1768
+ *
1769
+ * Features:
1770
+ * - Applies one or multiple `ReleaseAction` objects.
1771
+ * - Supports optimistic updates for create/edit/delete: local release state
1772
+ * reflects changes immediately while in-flight.
1773
+ * - Handles batching: multiple actions passed together are submitted as a
1774
+ * single atomic transaction.
1775
+ *
1776
+ * Release actions cannot be combined with `liveEdit` document actions in the
1777
+ * same transaction. Submit them as separate transactions if you need both.
1778
+ *
1779
+ * @category Releases
1780
+ * @returns A stable callback. When called with a single `ReleaseAction` or an
1781
+ * array of `ReleaseAction`s, it returns a promise that resolves to an
1782
+ * {@link ActionsResult}.
1783
+ *
1784
+ * @example Create and schedule a release
1785
+ * ```tsx
1786
+ * import {
1787
+ * createRelease,
1788
+ * scheduleRelease,
1789
+ * useApplyReleaseActions,
1790
+ * type ReleaseHandle,
1791
+ * } from '@sanity/sdk-react'
1792
+ *
1793
+ * function ScheduleReleaseButton({release}: {release: ReleaseHandle}) {
1794
+ * const applyRelease = useApplyReleaseActions()
1795
+ *
1796
+ * const handleSchedule = () =>
1797
+ * applyRelease([
1798
+ * createRelease(release, {title: 'Summer drop', releaseType: 'asap'}),
1799
+ * scheduleRelease(release, '2026-06-01T00:00:00Z'),
1800
+ * ])
1801
+ *
1802
+ * return <button onClick={handleSchedule}>Schedule</button>
1803
+ * }
1804
+ * ```
1805
+ *
1806
+ * @example Publish a release
1807
+ * ```tsx
1808
+ * import {publishRelease, useApplyReleaseActions} from '@sanity/sdk-react'
1809
+ *
1810
+ * function PublishButton({releaseId}: {releaseId: string}) {
1811
+ * const applyRelease = useApplyReleaseActions()
1812
+ * return (
1813
+ * <button onClick={() => applyRelease(publishRelease({releaseId}))}>
1814
+ * Publish all documents in the release
1815
+ * </button>
1816
+ * )
1817
+ * }
1818
+ * ```
1819
+ */
1820
+ export declare const useApplyReleaseActions: UseApplyReleaseActions;
1481
1821
 
1482
1822
  /**
1483
1823
  * @internal
@@ -1500,14 +1840,33 @@ export declare const useApplyDocumentActions: UseApplyDocumentActions
1500
1840
  * }
1501
1841
  * ```
1502
1842
  */
1503
- export declare const useAuthState: () => AuthState
1843
+ export declare const useAuthState: () => AuthState;
1504
1844
 
1505
1845
  /**
1506
1846
  * Hook to get the currently logged in user
1507
1847
  * @internal
1508
1848
  * @returns The current user or null if not authenticated
1509
1849
  */
1510
- export declare const useAuthToken: () => string | null
1850
+ export declare const useAuthToken: () => string | null;
1851
+
1852
+ /**
1853
+ * Checks whether the current user holds the given permissions on a resource.
1854
+ *
1855
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
1856
+ * `data` maps each requested permission to whether the user has it — keyed by
1857
+ * exactly the permission strings you passed.
1858
+ *
1859
+ * @public
1860
+ * @param resourceType - The type of resource (e.g. `'project'`, `'organization'`).
1861
+ * @param resourceId - The resource id.
1862
+ * @param permissions - The permission names to check.
1863
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
1864
+ */
1865
+ export declare const useCheckPermissions: <Permission extends string>(
1866
+ resourceType: AccessResourceType,
1867
+ resourceId: string,
1868
+ permissions: Permission[],
1869
+ ) => FetcherHookResult<Record<Permission, boolean>>;
1511
1870
 
1512
1871
  /**
1513
1872
  * A React hook that provides a client that subscribes to changes in your application,
@@ -1536,7 +1895,59 @@ export declare const useAuthToken: () => string | null
1536
1895
  * @public
1537
1896
  * @function
1538
1897
  */
1539
- export declare const useClient: (options: ClientOptions) => SanityClient
1898
+ export declare const useClient: (options: ClientOptions) => SanityClient;
1899
+
1900
+ /**
1901
+ * @public
1902
+ * Create a new document, relying on Typegen for the initial-value type.
1903
+ *
1904
+ * @param options - A document-type handle including `documentType`, an optional `documentId`, and optionally `projectId`/`dataset`/`perspective`.
1905
+ * @returns A function that creates the document. It accepts optional initial field values and an optional `{documentId}` override,
1906
+ * and resolves to the {@link DocumentHandle} of the created document (carrying the generated or supplied id).
1907
+ */
1908
+ export declare function useCreateDocument<
1909
+ TDocumentType extends string = string,
1910
+ TDataset extends string = string,
1911
+ TProjectId extends string = string,
1912
+ >(
1913
+ options: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>,
1914
+ ): (
1915
+ initialValue?: Partial<
1916
+ Omit<
1917
+ SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>,
1918
+ IgnoredKey
1919
+ >
1920
+ >,
1921
+ overrides?: CreateDocumentOverrides,
1922
+ ) => Promise<DocumentHandle<TDocumentType, TDataset, TProjectId>>;
1923
+
1924
+ /**
1925
+ * @public
1926
+ * Create a new document with an explicit type `TData`.
1927
+ *
1928
+ * @param options - A document-type handle including `documentType` and optionally `projectId`/`dataset`/`perspective`.
1929
+ * @returns A function that creates the document. It accepts optional initial field values (typed against `TData`) and an
1930
+ * optional `{documentId}` override, and resolves to the {@link DocumentHandle} of the created document.
1931
+ */
1932
+ export declare function useCreateDocument<
1933
+ TData extends Record<string, unknown>,
1934
+ >(
1935
+ options: DocumentTypeHandle,
1936
+ ): (
1937
+ initialValue?: Partial<Omit<TData, IgnoredKey>>,
1938
+ overrides?: CreateDocumentOverrides,
1939
+ ) => Promise<DocumentHandle>;
1940
+
1941
+ /**
1942
+ * Creates a user application.
1943
+ *
1944
+ * @internal
1945
+ * @returns The mutation envelope `{mutate, isPending, error, data, reset}`.
1946
+ */
1947
+ export declare const useCreateUserApplication: () => MutationHookResult<
1948
+ CreateUserApplicationInput,
1949
+ UserApplication
1950
+ >;
1540
1951
 
1541
1952
  declare type UseCurrentUser = {
1542
1953
  /**
@@ -1559,15 +1970,15 @@ declare type UseCurrentUser = {
1559
1970
  * )
1560
1971
  * ```
1561
1972
  */
1562
- (): CurrentUser | null
1563
- }
1973
+ (): CurrentUser | null;
1974
+ };
1564
1975
 
1565
1976
  /**
1566
1977
  * @public
1567
1978
  * @function
1568
1979
  * @TODO This should not return null — users of a custom app will always be authenticated via Core
1569
1980
  */
1570
- export declare const useCurrentUser: UseCurrentUser
1981
+ export declare const useCurrentUser: UseCurrentUser;
1571
1982
 
1572
1983
  /**
1573
1984
  * @public
@@ -1613,8 +2024,8 @@ export declare const useCurrentUser: UseCurrentUser
1613
2024
  * ```
1614
2025
  */
1615
2026
  export declare function useDashboardNavigate(
1616
- navigateFn: (options: PathChangeMessage['data']) => void,
1617
- ): void
2027
+ navigateFn: (options: PathChangeMessage["data"]) => void,
2028
+ ): void;
1618
2029
 
1619
2030
  /**
1620
2031
  * @public
@@ -1635,7 +2046,7 @@ export declare function useDashboardNavigate(
1635
2046
  * @category Dashboard
1636
2047
  * @returns The dashboard organization ID (string | undefined)
1637
2048
  */
1638
- export declare function useDashboardOrganizationId(): string | undefined
2049
+ export declare function useDashboardOrganizationId(): string | undefined;
1639
2050
 
1640
2051
  declare type UseDatasets = {
1641
2052
  /**
@@ -1643,12 +2054,13 @@ declare type UseDatasets = {
1643
2054
  * Returns metadata for each dataset the current user has access to.
1644
2055
  *
1645
2056
  * @category Datasets
1646
- * @param options - An object containing the `projectId` to list datasets for.
1647
- * @returns The metadata for the datasets
2057
+ * @param options - Optional project/resource to read datasets for. Defaults to
2058
+ * the resource named in `ResourceProvider`/`SDKProvider`.
2059
+ * @returns The metadata for your the datasets
1648
2060
  *
1649
2061
  * @example
1650
2062
  * ```tsx
1651
- * const datasets = useDatasets({projectId: 'my-project-id'})
2063
+ * const datasets = useDatasets()
1652
2064
  *
1653
2065
  * return (
1654
2066
  * <select>
@@ -1659,204 +2071,248 @@ declare type UseDatasets = {
1659
2071
  * )
1660
2072
  * ```
1661
2073
  *
2074
+ * @remarks
2075
+ * The `projectId` is resolved in order from:
2076
+ * 1. an explicit `projectId` option
2077
+ * 2. A legacy ProjectContext (e.g. a `<ResourceProvider projectId="…">` with no dataset), then
2078
+ * 3. The active resource (`ResourceProvider`/`SDKProvider`)
2079
+ * 4. `instance.config`.
1662
2080
  */
1663
- (options: {projectId: string}): DatasetsResponse
1664
- }
2081
+ (options?: ProjectHandle): DatasetsResponse;
2082
+ };
1665
2083
 
1666
2084
  /**
1667
2085
  * @public
1668
2086
  * @function
1669
2087
  */
1670
- export declare const useDatasets: UseDatasets
2088
+ export declare const useDatasets: UseDatasets;
1671
2089
 
1672
2090
  /**
1673
- * @beta
1674
- *
1675
- * A hook for dispatching intent messages to the Dashboard with a document handle.
1676
- * This allows applications to signal their intent to pass the referenced document to other applications that have registered the ability to perform specific actions on that document.
2091
+ * Soft-deletes an application.
1677
2092
  *
1678
- * @param params - Object containing:
1679
- * - `action` - Action to perform (currently only 'edit' is supported). Will prompt a picker if multiple handlers are available.
1680
- * - `intentId` - Specific ID of the intent to dispatch. Either `action` or `intentId` is required.
1681
- * - `documentHandle` - The document handle containing document ID, type, and either:
1682
- * - `projectId` and `dataset` for traditional dataset resources, like `{documentId: '123', documentType: 'book', projectId: 'abc123', dataset: 'production'}`
1683
- * - `resource` for media library, canvas, or dataset resources, like `{documentId: '123', documentType: 'sanity.asset', resource: mediaLibraryResource('ml123')}` or `{documentId: '123', documentType: 'sanity.canvas.document', resource: canvasResource('canvas123')}`
1684
- * - `paremeters` - Optional parameters to include in the dispatch; will be passed to the resolved intent handler
1685
- * @returns An object containing:
1686
- * - `dispatchIntent` - Function to dispatch the intent message
1687
- *
1688
- * @example
1689
- * ```tsx
1690
- * import {useDispatchIntent} from '@sanity/sdk-react'
1691
- * import {Button} from '@sanity/ui'
1692
- * import {Suspense} from 'react'
1693
- *
1694
- * function DispatchIntentButton({documentId, documentType, projectId, dataset}) {
1695
- * const {dispatchIntent} = useDispatchIntent({
1696
- * action: 'edit',
1697
- * documentHandle: {documentId, documentType, projectId, dataset},
1698
- * })
1699
- *
1700
- * return (
1701
- * <Button
1702
- * onClick={() => dispatchIntent()}
1703
- * text="Dispatch Intent"
1704
- * />
1705
- * )
1706
- * }
1707
- *
1708
- * // Wrap the component with Suspense since the hook may suspend
1709
- * function MyDocumentAction({documentId, documentType, projectId, dataset}) {
1710
- * return (
1711
- * <Suspense fallback={<Button text="Loading..." disabled />}>
1712
- * <DispatchIntentButton
1713
- * documentId={documentId}
1714
- * documentType={documentType}
1715
- * projectId={projectId}
1716
- * dataset={dataset}
1717
- * />
1718
- * </Suspense>
1719
- * )
1720
- * }
1721
- * ```
2093
+ * @internal
2094
+ * @returns The mutation envelope `{mutate, isPending, error, data, reset}`.
1722
2095
  */
1723
- export declare function useDispatchIntent(params: UseDispatchIntentParams): DispatchIntent
2096
+ export declare const useDeleteApplication: () => MutationHookResult<
2097
+ DeleteApplicationInput,
2098
+ DeletedResult
2099
+ >;
1724
2100
 
1725
2101
  /**
1726
- * Parameters for the useDispatchIntent hook
1727
- * @beta
2102
+ * Deletes a user application.
2103
+ *
2104
+ * @internal
2105
+ * @returns The mutation envelope `{mutate, isPending, error, data, reset}`.
1728
2106
  */
1729
- declare interface UseDispatchIntentParams {
1730
- action?: 'edit'
1731
- intentId?: string
1732
- documentHandle: DocumentHandle
1733
- parameters?: Record<string, unknown>
1734
- }
2107
+ export declare const useDeleteUserApplication: () => MutationHookResult<
2108
+ DeleteUserApplicationInput,
2109
+ DeletedResult
2110
+ >;
1735
2111
 
1736
2112
  declare interface UseDocument {
2113
+ /** @internal */
2114
+ <
2115
+ TDocumentType extends string,
2116
+ TDataset extends string,
2117
+ TProjectId extends string = string,
2118
+ >(
2119
+ options: UseDocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
2120
+ ): {
2121
+ data: SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`> | null;
2122
+ };
2123
+ /** @internal */
2124
+ <
2125
+ TPath extends string,
2126
+ TDocumentType extends string,
2127
+ TDataset extends string = string,
2128
+ TProjectId extends string = string,
2129
+ >(
2130
+ options: UseDocumentOptions<TPath, TDocumentType>,
2131
+ ): {
2132
+ data:
2133
+ | JsonMatch<
2134
+ SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>,
2135
+ TPath
2136
+ >
2137
+ | undefined;
2138
+ };
2139
+ /** @internal */
2140
+ <TData>(options: DocumentOptions<undefined>): {
2141
+ data: TData | null;
2142
+ };
2143
+ /** @internal */
2144
+ <TData>(options: DocumentOptions<string>): {
2145
+ data: TData | undefined;
2146
+ };
1737
2147
  /**
2148
+ * ## useDocument via Type Inference (Recommended)
2149
+ *
1738
2150
  * @public
1739
2151
  *
1740
- * ## useDocument with Explicit Types (no path)
2152
+ * The preferred way to use this hook when working with Sanity Typegen.
1741
2153
  *
1742
- * Provide an explicit type parameter `TData` to type the returned document data.
1743
- * You can define your own interfaces or use types generated by your Sanity Studio.
2154
+ * Features:
2155
+ * - Automatically infers document types from your schema
2156
+ * - Provides type-safe access to documents and nested fields
2157
+ * - Supports project/dataset-specific type inference
2158
+ * - Works seamlessly with Typegen-generated types
1744
2159
  *
1745
- * This hook will suspend while the document data is being fetched.
2160
+ * This hook will suspend while the document data is being fetched and loaded.
2161
+ *
2162
+ * When fetching a full document:
2163
+ * - Returns the complete document object if it exists
2164
+ * - Returns `null` if the document doesn't exist
1746
2165
  *
1747
- * @typeParam TData - The explicit type for the document
2166
+ * When fetching with a path:
2167
+ * - Returns the value at the specified path if both the document and path exist
2168
+ * - Returns `undefined` if either the document doesn't exist or the path doesn't exist in the document
2169
+ *
2170
+ * @category Documents
1748
2171
  * @param options - Configuration including `documentId`, `documentType`, and optionally:
2172
+ * - `path`: To select a nested value (returns typed value at path)
1749
2173
  * - `projectId`/`dataset`: For multi-project/dataset setups
1750
- * @returns The document state
2174
+ * @returns The document state (or nested value if path provided).
1751
2175
  *
1752
- * @example Basic document fetch with explicit type
2176
+ * @example Basic document fetch
1753
2177
  * ```tsx
1754
- * import {useDocument, type DocumentHandle, type SanityDocument} from '@sanity/sdk-react'
1755
- *
1756
- * interface Book extends SanityDocument {
1757
- * _type: 'book'
1758
- * title: string
1759
- * author: string
1760
- * }
2178
+ * import {useDocument, type DocumentHandle} from '@sanity/sdk-react'
1761
2179
  *
1762
- * interface BookViewProps {
1763
- * doc: DocumentHandle
2180
+ * interface ProductViewProps {
2181
+ * doc: DocumentHandle<'product'> // Typegen infers product type
1764
2182
  * }
1765
2183
  *
1766
- * function BookView({doc}: BookViewProps) {
1767
- * const {data: book} = useDocument<Book>({...doc})
1768
- * return <h1>{book?.title ?? 'Untitled'} by {book?.author ?? 'Unknown'}</h1>
2184
+ * function ProductView({doc}: ProductViewProps) {
2185
+ * const {data: product} = useDocument({...doc}) // Fully typed product
2186
+ * return <h1>{product.title ?? 'Untitled'}</h1>
1769
2187
  * }
1770
2188
  * ```
1771
2189
  *
1772
- * @inlineType DocumentOptions
1773
- */
1774
- <TData>(options: UseDocumentOptions<undefined>): {
1775
- data: TData | null
1776
- }
1777
- /**
1778
- * @public
1779
- *
1780
- * ## useDocument with Explicit Types (with path)
1781
- *
1782
- * Provide an explicit type parameter `TData` to type the returned field data
1783
- * when using a `path` to select a nested value.
1784
- *
1785
- * @typeParam TData - The explicit type for the field
1786
- * @param options - Configuration including `documentId`, `documentType`, `path`, and optionally:
1787
- * - `projectId`/`dataset`: For multi-project/dataset setups
1788
- * @returns The field value at the specified path
1789
- *
1790
- * @example Fetching a specific field with explicit type
2190
+ * @example Fetching a specific field
1791
2191
  * ```tsx
1792
2192
  * import {useDocument, type DocumentHandle} from '@sanity/sdk-react'
1793
2193
  *
1794
- * function BookTitle({doc}: {doc: DocumentHandle}) {
1795
- * const {data: title} = useDocument<string>({...doc, path: 'title'})
2194
+ * interface ProductTitleProps {
2195
+ * doc: DocumentHandle<'product'>
2196
+ * }
2197
+ *
2198
+ * function ProductTitle({doc}: ProductTitleProps) {
2199
+ * const {data: title} = useDocument({
2200
+ * ...doc,
2201
+ * path: 'title' // Returns just the title field
2202
+ * })
1796
2203
  * return <h1>{title ?? 'Untitled'}</h1>
1797
2204
  * }
1798
2205
  * ```
1799
2206
  *
1800
2207
  * @inlineType DocumentOptions
1801
2208
  */
1802
- <TData>(options: UseDocumentOptions<string>): {
1803
- data: TData | undefined
1804
- }
2209
+ <
2210
+ TPath extends string | undefined = undefined,
2211
+ TDocumentType extends string = string,
2212
+ TDataset extends string = string,
2213
+ TProjectId extends string = string,
2214
+ >(
2215
+ options: UseDocumentOptions<TPath, TDocumentType>,
2216
+ ): TPath extends string
2217
+ ? {
2218
+ data:
2219
+ | JsonMatch<
2220
+ SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>,
2221
+ TPath
2222
+ >
2223
+ | undefined;
2224
+ }
2225
+ : {
2226
+ data: SanityDocument_2<
2227
+ TDocumentType,
2228
+ `${TProjectId}.${TDataset}`
2229
+ > | null;
2230
+ };
1805
2231
  /**
1806
2232
  * @public
1807
2233
  *
1808
- * ## useDocument (default)
2234
+ * ## useDocument via Explicit Types
1809
2235
  *
1810
- * When no explicit type parameter is provided, the hook returns `SanityDocument`.
2236
+ * Use this version when:
2237
+ * - You're not using Sanity Typegen
2238
+ * - You need to manually specify document types
2239
+ * - You're working with dynamic document types
1811
2240
  *
1812
- * This hook will suspend while the document data is being fetched and loaded.
2241
+ * Key differences from Typegen version:
2242
+ * - Requires manual type specification via `TData`
2243
+ * - Returns `TData | null` for full documents
2244
+ * - Returns `TData | undefined` for nested values
1813
2245
  *
1814
- * When fetching a full document:
1815
- * - Returns the complete document object if it exists
1816
- * - Returns `null` if the document doesn't exist
1817
- *
1818
- * When fetching with a path:
1819
- * - Returns the value at the specified path if both the document and path exist
1820
- * - Returns `undefined` if either the document doesn't exist or the path doesn't exist in the document
2246
+ * This hook will suspend while the document data is being fetched.
1821
2247
  *
1822
- * @category Documents
1823
- * @param options - Configuration including `documentId`, `documentType`, and optionally:
2248
+ * @typeParam TData - The explicit type for the document or field
2249
+ * @typeParam TPath - Optional path to a nested value
2250
+ * @param options - Configuration including `documentId` and optionally:
1824
2251
  * - `path`: To select a nested value
1825
2252
  * - `projectId`/`dataset`: For multi-project/dataset setups
1826
- * @returns The document state (or nested value if path provided).
2253
+ * @returns The document state (or nested value if path provided)
2254
+ *
2255
+ * @example Basic document fetch with explicit type
2256
+ * ```tsx
2257
+ * import {useDocument, type DocumentHandle, type SanityDocument} from '@sanity/sdk-react'
2258
+ *
2259
+ * interface Book extends SanityDocument {
2260
+ * _type: 'book'
2261
+ * title: string
2262
+ * author: string
2263
+ * }
2264
+ *
2265
+ * interface BookViewProps {
2266
+ * doc: DocumentHandle
2267
+ * }
2268
+ *
2269
+ * function BookView({doc}: BookViewProps) {
2270
+ * const {data: book} = useDocument<Book>({...doc})
2271
+ * return <h1>{book?.title ?? 'Untitled'} by {book?.author ?? 'Unknown'}</h1>
2272
+ * }
2273
+ * ```
1827
2274
  *
1828
- * @example Basic document fetch
2275
+ * @example Fetching a specific field with explicit type
1829
2276
  * ```tsx
1830
2277
  * import {useDocument, type DocumentHandle} from '@sanity/sdk-react'
1831
2278
  *
1832
- * function ProductView({doc}: {doc: DocumentHandle}) {
1833
- * const {data: product} = useDocument({...doc})
1834
- * return <h1>{product?.title ?? 'Untitled'}</h1>
2279
+ * interface BookTitleProps {
2280
+ * doc: DocumentHandle
2281
+ * }
2282
+ *
2283
+ * function BookTitle({doc}: BookTitleProps) {
2284
+ * const {data: title} = useDocument<string>({...doc, path: 'title'})
2285
+ * return <h1>{title ?? 'Untitled'}</h1>
1835
2286
  * }
1836
2287
  * ```
1837
2288
  *
1838
2289
  * @inlineType DocumentOptions
1839
2290
  */
1840
- (options: UseDocumentOptions<undefined>): {
1841
- data: SanityDocument | null
1842
- }
2291
+ <TData, TPath extends string>(
2292
+ options: UseDocumentOptions<TPath>,
2293
+ ): TPath extends string
2294
+ ? {
2295
+ data: TData | undefined;
2296
+ }
2297
+ : {
2298
+ data: TData | null;
2299
+ };
1843
2300
  /**
1844
2301
  * @internal
1845
2302
  */
1846
2303
  (options: UseDocumentOptions): {
1847
- data: unknown
1848
- }
2304
+ data: unknown;
2305
+ };
1849
2306
  }
1850
2307
 
1851
2308
  /**
1852
2309
  * @public
1853
2310
  * Reads and subscribes to a document's realtime state, incorporating both local and remote changes.
1854
2311
  *
1855
- * You can provide an explicit type parameter for full type safety:
1856
- * - `useDocument<MyType>({...})` returns `{data: MyType | null}`
1857
- * - `useDocument<string>({..., path: 'title'})` returns `{data: string | undefined}`
2312
+ * This hook comes in two main flavors to suit your needs:
1858
2313
  *
1859
- * Without a type parameter, data is typed as `SanityDocument`.
2314
+ * 1. **[Type Inference](#usedocument-via-type-inference-recommended)** (Recommended) - Automatically gets types from your Sanity schema
2315
+ * 2. **[Explicit Types](#usedocument-via-explicit-types)** - Manually specify types when needed
1860
2316
  *
1861
2317
  * @remarks
1862
2318
  * `useDocument` is ideal for realtime editing interfaces where you need immediate feedback on changes.
@@ -1872,7 +2328,7 @@ declare interface UseDocument {
1872
2328
  *
1873
2329
  * @function
1874
2330
  */
1875
- export declare const useDocument: UseDocument
2331
+ export declare const useDocument: UseDocument;
1876
2332
 
1877
2333
  /**
1878
2334
  *
@@ -1881,19 +2337,19 @@ export declare const useDocument: UseDocument
1881
2337
  * Subscribes an event handler to events in your application's document store.
1882
2338
  *
1883
2339
  * @category Documents
1884
- * @param options - An object containing the event handler (`onEvent`) and optionally a `resource`. If no resource is provided, the nearest resource from context will be used.
2340
+ * @param options - An object containing the event handler (`onEvent`) and optionally a `DatasetHandle` (projectId and dataset). If the handle is not provided, the nearest Sanity instance from context will be used.
1885
2341
  * @example Creating a custom hook for document event toasts
1886
2342
  * ```tsx
1887
- * import {type DocumentResource, type DocumentEvent, useDocumentEvent} from '@sanity/sdk-react'
2343
+ * import {createDatasetHandle, type DatasetHandle, type DocumentEvent, useDocumentEvent} from '@sanity/sdk-react'
1888
2344
  * import {useToast} from './my-ui-library'
1889
2345
  *
1890
- * // Define options for the custom hook
1891
- * interface DocumentToastsOptions {
1892
- * resource?: DocumentResource
2346
+ * // Define options for the custom hook, extending DatasetHandle
2347
+ * interface DocumentToastsOptions extends DatasetHandle {
2348
+ * // Could add more options, e.g., { includeEvents: DocumentEvent['type'][] }
1893
2349
  * }
1894
2350
  *
1895
2351
  * // Define the custom hook
1896
- * function useDocumentToasts({resource}: DocumentToastsOptions = {}) {
2352
+ * function useDocumentToasts({...datasetHandle}: DocumentToastsOptions = {}) {
1897
2353
  * const showToast = useToast() // Get the toast function
1898
2354
  *
1899
2355
  * // Define the event handler logic to show toasts on specific events
@@ -1905,20 +2361,24 @@ export declare const useDocument: UseDocument
1905
2361
  * } else if (event.type === 'deleted') {
1906
2362
  * showToast(`Document ${event.documentId} deleted.`)
1907
2363
  * } else {
2364
+ * // Optionally log other events for debugging
1908
2365
  * console.log('Document Event:', event.type, event.documentId)
1909
2366
  * }
1910
2367
  * }
1911
2368
  *
2369
+ * // Call the original hook, spreading the handle properties
1912
2370
  * useDocumentEvent({
1913
- * resource,
2371
+ * ...datasetHandle, // Spread the dataset handle (projectId, dataset)
1914
2372
  * onEvent: handleEvent,
1915
2373
  * })
1916
2374
  * }
1917
2375
  *
1918
2376
  * function MyComponentWithToasts() {
1919
- * useDocumentToasts({resource: {projectId: 'p1', dataset: 'ds1'}})
2377
+ * // Use the custom hook, passing specific handle info
2378
+ * const specificHandle = createDatasetHandle({ projectId: 'p1', dataset: 'ds1' })
2379
+ * useDocumentToasts(specificHandle)
1920
2380
  *
1921
- * // Or rely on context for the resource:
2381
+ * // // Or use it relying on context for the handle
1922
2382
  * // useDocumentToasts()
1923
2383
  *
1924
2384
  * return <div>...</div>
@@ -1928,7 +2388,7 @@ export declare const useDocument: UseDocument
1928
2388
  export declare function useDocumentEvent<
1929
2389
  TDataset extends string = string,
1930
2390
  TProjectId extends string = string,
1931
- >(options: UseDocumentEventOptions<TDataset, TProjectId>): void
2391
+ >(options: UseDocumentEventOptions<TDataset, TProjectId>): void;
1932
2392
 
1933
2393
  /**
1934
2394
  * @public
@@ -1936,8 +2396,8 @@ export declare function useDocumentEvent<
1936
2396
  declare interface UseDocumentEventOptions<
1937
2397
  TDataset extends string = string,
1938
2398
  TProjectId extends string = string,
1939
- > extends ResourceHandle<TProjectId, TDataset> {
1940
- onEvent: (documentEvent: DocumentEvent) => void
2399
+ > extends ResourceHandle<TDataset, TProjectId> {
2400
+ onEvent: (documentEvent: DocumentEvent) => void;
1941
2401
  }
1942
2402
 
1943
2403
  declare type UseDocumentOptions<
@@ -1946,8 +2406,8 @@ declare type UseDocumentOptions<
1946
2406
  TDataset extends string = string,
1947
2407
  TProjectId extends string = string,
1948
2408
  > = DocumentHandle<TDocumentType, TDataset, TProjectId> & {
1949
- path?: TPath
1950
- }
2409
+ path?: TPath;
2410
+ };
1951
2411
 
1952
2412
  /**
1953
2413
  *
@@ -2027,8 +2487,10 @@ declare type UseDocumentOptions<
2027
2487
  * ```
2028
2488
  */
2029
2489
  export declare function useDocumentPermissions(
2030
- actionOrActions: DocumentAction | DocumentAction[],
2031
- ): DocumentPermissionsResult
2490
+ actionOrActions:
2491
+ | WithResourceNameSupport<DocumentAction>
2492
+ | WithResourceNameSupport<DocumentAction>[],
2493
+ ): DocumentPermissionsResult;
2032
2494
 
2033
2495
  /**
2034
2496
  * @public
@@ -2056,9 +2518,9 @@ export declare function useDocumentPermissions(
2056
2518
  *
2057
2519
  * @example Combining with useDocuments to render a collection of document previews
2058
2520
  * ```
2059
- * // PreviewComponent.tsx
2060
- * export default function PreviewComponent(docHandle: DocumentHandle) {
2061
- * const { data: { title, subtitle, media }, isPending } = useDocumentPreview(docHandle)
2521
+ * // PreviewComponent.jsx
2522
+ * export default function PreviewComponent({ document }) {
2523
+ * const { data: { title, subtitle, media }, isPending } = useDocumentPreview({ document })
2062
2524
  * return (
2063
2525
  * <article style={{ opacity: isPending ? 0.5 : 1}}>
2064
2526
  * {media?.type === 'image-asset' ? <img src={media.url} alt='' /> : ''}
@@ -2068,16 +2530,16 @@ export declare function useDocumentPermissions(
2068
2530
  * )
2069
2531
  * }
2070
2532
  *
2071
- * // DocumentList.tsx
2072
- * const { data } = useDocuments({ documentType: 'movie' })
2533
+ * // DocumentList.jsx
2534
+ * const { data } = useDocuments({ filter: '_type == "movie"' })
2073
2535
  * return (
2074
2536
  * <div>
2075
2537
  * <h1>Movies</h1>
2076
2538
  * <ul>
2077
2539
  * {data.map(movie => (
2078
- * <li key={movie.documentId}>
2540
+ * <li key={movie._id}>
2079
2541
  * <Suspense fallback='Loading…'>
2080
- * <PreviewComponent {...movie} />
2542
+ * <PreviewComponent document={movie} />
2081
2543
  * </Suspense>
2082
2544
  * </li>
2083
2545
  * ))}
@@ -2089,7 +2551,7 @@ export declare function useDocumentPermissions(
2089
2551
  export declare function useDocumentPreview({
2090
2552
  ref,
2091
2553
  ...docHandle
2092
- }: useDocumentPreviewOptions): useDocumentPreviewResults
2554
+ }: useDocumentPreviewOptions): useDocumentPreviewResults;
2093
2555
 
2094
2556
  /**
2095
2557
  * @public
@@ -2100,7 +2562,7 @@ export declare interface useDocumentPreviewOptions extends DocumentHandle {
2100
2562
  * Optional ref object to track visibility. When provided, preview resolution
2101
2563
  * only occurs when the referenced element is visible in the viewport.
2102
2564
  */
2103
- ref?: React.RefObject<unknown>
2565
+ ref?: React.RefObject<unknown>;
2104
2566
  }
2105
2567
 
2106
2568
  /**
@@ -2109,9 +2571,9 @@ export declare interface useDocumentPreviewOptions extends DocumentHandle {
2109
2571
  */
2110
2572
  export declare interface useDocumentPreviewResults {
2111
2573
  /** The results of inferring the document's preview values */
2112
- data: PreviewValue
2574
+ data: PreviewValue;
2113
2575
  /** True when inferred preview values are being refreshed */
2114
- isPending: boolean
2576
+ isPending: boolean;
2115
2577
  }
2116
2578
 
2117
2579
  /**
@@ -2124,11 +2586,89 @@ export declare interface useDocumentPreviewResults {
2124
2586
  *
2125
2587
  * @category Documents
2126
2588
  * @remarks
2127
- * This hook allows specifying an explicit type parameter `TData` for the projected result.
2589
+ * This hook has multiple signatures allowing for fine-grained control over type inference:
2590
+ * - Using Typegen: Infers the return type based on the `documentType`, `dataset`, `projectId`, and `projection`.
2591
+ * - Using explicit type parameter: Allows specifying a custom return type `TData`.
2128
2592
  *
2129
2593
  * @param options - An object containing the `DocumentHandle` properties (`documentId`, `documentType`, etc.), the `projection` string, optional `params`, and an optional `ref`.
2130
2594
  * @returns An object containing the projection results (`data`) and a boolean indicating whether the resolution is pending (`isPending`). Note: Suspense handles initial loading states; `data` being `undefined` after initial loading means the document doesn't exist or the projection yielded no result.
2131
2595
  */
2596
+ /**
2597
+ * @public
2598
+ * Fetch a projection, relying on Typegen for the return type based on the handle and projection.
2599
+ *
2600
+ * @category Documents
2601
+ * @param options - Options including the document handle properties (`documentId`, `documentType`, etc.) and the `projection`.
2602
+ * @returns The projected data, typed based on Typegen.
2603
+ *
2604
+ * @example Using Typegen for a book preview
2605
+ * ```tsx
2606
+ * // ProjectionComponent.tsx
2607
+ * import {useDocumentProjection, type DocumentHandle} from '@sanity/sdk-react'
2608
+ * import {useRef} from 'react'
2609
+ * import {defineProjection} from 'groq'
2610
+ *
2611
+ * // Define props using DocumentHandle with the specific document type
2612
+ * type ProjectionComponentProps = {
2613
+ * doc: DocumentHandle<'book'> // Typegen knows 'book'
2614
+ * }
2615
+ *
2616
+ * // This is required for typegen to generate the correct return type
2617
+ * const myProjection = defineProjection(`{
2618
+ * title,
2619
+ * 'coverImage': cover.asset->url,
2620
+ * 'authors': array::join(authors[]->{'name': firstName + ' ' + lastName}.name, ', ')
2621
+ * }`)
2622
+ *
2623
+ * export default function ProjectionComponent({ doc }: ProjectionComponentProps) {
2624
+ * const ref = useRef(null) // Optional ref to track viewport intersection for lazy loading
2625
+ *
2626
+ * // Spread the doc handle into the options
2627
+ * // Typegen infers the return type based on 'book' and the projection
2628
+ * const { data } = useDocumentProjection({
2629
+ * ...doc, // Pass the handle properties
2630
+ * ref,
2631
+ * projection: myProjection,
2632
+ * })
2633
+ *
2634
+ * // Suspense handles initial load, check for data existence after
2635
+ * return (
2636
+ * <article ref={ref}>
2637
+ * <h2>{data.title ?? 'Untitled'}</h2>
2638
+ * {data.coverImage && <img src={data.coverImage} alt={data.title} />}
2639
+ * <p>{data.authors ?? 'Unknown authors'}</p>
2640
+ * </article>
2641
+ * )
2642
+ * }
2643
+ *
2644
+ * // Usage:
2645
+ * // import {createDocumentHandle} from '@sanity/sdk-react'
2646
+ * // const myDocHandle = createDocumentHandle({ documentId: 'book123', documentType: 'book' })
2647
+ * // <Suspense fallback='Loading preview...'>
2648
+ * // <ProjectionComponent doc={myDocHandle} />
2649
+ * // </Suspense>
2650
+ * ```
2651
+ */
2652
+ export declare function useDocumentProjection<
2653
+ TProjection extends string = string,
2654
+ TDocumentType extends string = string,
2655
+ TDataset extends string = string,
2656
+ TProjectId extends string = string,
2657
+ >(
2658
+ options: useDocumentProjectionOptions<
2659
+ TProjection,
2660
+ TDocumentType,
2661
+ TDataset,
2662
+ TProjectId
2663
+ >,
2664
+ ): useDocumentProjectionResults<
2665
+ SanityProjectionResult<
2666
+ TProjection,
2667
+ TDocumentType,
2668
+ `${TProjectId}.${TDataset}`
2669
+ >
2670
+ >;
2671
+
2132
2672
  /**
2133
2673
  * @public
2134
2674
  * Fetch a projection with an explicitly defined return type `TData`.
@@ -2176,7 +2716,7 @@ export declare interface useDocumentPreviewResults {
2176
2716
  */
2177
2717
  export declare function useDocumentProjection<TData extends object>(
2178
2718
  options: useDocumentProjectionOptions,
2179
- ): useDocumentProjectionResults<TData>
2719
+ ): useDocumentProjectionResults<TData>;
2180
2720
 
2181
2721
  /**
2182
2722
  * @public
@@ -2189,11 +2729,11 @@ export declare interface useDocumentProjectionOptions<
2189
2729
  TProjectId extends string = string,
2190
2730
  > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2191
2731
  /** The GROQ projection string */
2192
- projection: TProjection
2732
+ projection: TProjection;
2193
2733
  /** Optional parameters for the projection query */
2194
- params?: Record<string, unknown>
2734
+ params?: Record<string, unknown>;
2195
2735
  /** Optional ref to track viewport intersection for lazy loading */
2196
- ref?: React.RefObject<unknown>
2736
+ ref?: React.RefObject<unknown>;
2197
2737
  }
2198
2738
 
2199
2739
  /**
@@ -2202,9 +2742,9 @@ export declare interface useDocumentProjectionOptions<
2202
2742
  */
2203
2743
  export declare interface useDocumentProjectionResults<TData> {
2204
2744
  /** The projected data */
2205
- data: TData
2745
+ data: TData;
2206
2746
  /** True if the projection is currently being resolved */
2207
- isPending: boolean
2747
+ isPending: boolean;
2208
2748
  }
2209
2749
 
2210
2750
  /**
@@ -2218,16 +2758,18 @@ export declare interface useDocumentProjectionResults<TData> {
2218
2758
  * @returns An object containing the list of document handles, the loading state, the total count of retrieved document handles, and a function to load more
2219
2759
  *
2220
2760
  * @remarks
2221
- * - The returned document handles include resource information from the current Sanity instance
2761
+ * - The returned document handles include projectId and dataset information from the current Sanity instance
2222
2762
  * - This makes them ready to use with document operations and other document hooks
2223
- * - The hook automatically uses the correct Sanity instance based on the resource in the options
2763
+ * - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
2224
2764
  *
2225
2765
  * @example Basic infinite list with loading more
2226
2766
  * ```tsx
2227
2767
  * import {
2228
2768
  * useDocuments,
2769
+ * createDatasetHandle,
2770
+ * type DatasetHandle,
2229
2771
  * type DocumentHandle,
2230
- * type DocumentResource,
2772
+ * type SortOrderingItem
2231
2773
  * } from '@sanity/sdk-react'
2232
2774
  * import {Suspense} from 'react'
2233
2775
  *
@@ -2243,14 +2785,14 @@ export declare interface useDocumentProjectionResults<TData> {
2243
2785
  *
2244
2786
  * // Define props for the list component
2245
2787
  * interface DocumentListProps {
2246
- * resource: DocumentResource
2788
+ * dataset: DatasetHandle
2247
2789
  * documentType: string
2248
2790
  * search?: string
2249
2791
  * }
2250
2792
  *
2251
- * function DocumentList({resource, documentType, search}: DocumentListProps) {
2793
+ * function DocumentList({dataset, documentType, search}: DocumentListProps) {
2252
2794
  * const { data, hasMore, isPending, loadMore, count } = useDocuments({
2253
- * resource,
2795
+ * ...dataset,
2254
2796
  * documentType,
2255
2797
  * search,
2256
2798
  * batchSize: 10,
@@ -2264,7 +2806,7 @@ export declare interface useDocumentProjectionResults<TData> {
2264
2806
  * {data.map((docHandle) => (
2265
2807
  * <li key={docHandle.documentId}>
2266
2808
  * <Suspense fallback="Loading…">
2267
- * <MyDocumentComponent doc={docHandle} />
2809
+ * <MyDocumentComponent docHandle={docHandle} />
2268
2810
  * </Suspense>
2269
2811
  * </li>
2270
2812
  * ))}
@@ -2279,7 +2821,8 @@ export declare interface useDocumentProjectionResults<TData> {
2279
2821
  * }
2280
2822
  *
2281
2823
  * // Usage:
2282
- * // <DocumentList resource={{projectId: 'p1', dataset: 'production'}} documentType="post" search="Sanity" />
2824
+ * // const myDatasetHandle = createDatasetHandle({ projectId: 'p1', dataset: 'production' })
2825
+ * // <DocumentList dataset={myDatasetHandle} documentType="post" search="Sanity" />
2283
2826
  * ```
2284
2827
  *
2285
2828
  * @example Using `filter` and `params` options for narrowing a collection
@@ -2329,16 +2872,16 @@ export declare function useDocuments<
2329
2872
  TDocumentType,
2330
2873
  TDataset,
2331
2874
  TProjectId
2332
- >
2875
+ >;
2333
2876
 
2334
2877
  declare type UseDocumentSyncStatus = {
2335
2878
  /**
2336
2879
  * Exposes the document's sync status between local and remote document states.
2337
2880
  *
2338
2881
  * @category Documents
2339
- * @param doc - The document handle to get sync status for. If you pass a `resource` in the handle,
2340
- * the document will be read from the specified resource. If no `resource` is provided,
2341
- * the resource will be resolved from context.
2882
+ * @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with specified `projectId` and `dataset`,
2883
+ * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `projectId` or `dataset` is provided,
2884
+ * the document will use the nearest instance from context.
2342
2885
  * @returns `true` if local changes are synced with remote, `false` if changes are pending. Note: Suspense handles loading states.
2343
2886
  * @example Show sync status indicator
2344
2887
  * ```tsx
@@ -2364,38 +2907,86 @@ declare type UseDocumentSyncStatus = {
2364
2907
  * // <SyncIndicator doc={doc} />
2365
2908
  * ```
2366
2909
  */
2367
- (doc: DocumentHandle): boolean
2368
- }
2910
+ (doc: DocumentHandle_2): boolean;
2911
+ };
2369
2912
 
2370
2913
  /**
2371
2914
  * @public
2372
2915
  * @function
2373
2916
  */
2374
- export declare const useDocumentSyncStatus: UseDocumentSyncStatus
2917
+ export declare const useDocumentSyncStatus: UseDocumentSyncStatus;
2918
+
2919
+ /**
2920
+ * @public
2921
+ * Edit an entire document, relying on Typegen for the type.
2922
+ *
2923
+ * @param options - Document options including `documentId`, `documentType`, and optionally `projectId`/`dataset`.
2924
+ * @returns A stable function to update the document state. Accepts either the new document state or an updater function `(currentValue) => nextValue`.
2925
+ * Returns a promise resolving to the {@link ActionsResult}.
2926
+ */
2927
+ export declare function useEditDocument<
2928
+ TDocumentType extends string = string,
2929
+ TDataset extends string = string,
2930
+ TProjectId extends string = string,
2931
+ >(
2932
+ options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
2933
+ ): (
2934
+ nextValue: Updater<
2935
+ SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>
2936
+ >,
2937
+ ) => Promise<
2938
+ ActionsResult<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>>
2939
+ >;
2940
+
2941
+ /**
2942
+ * @public
2943
+ * Edit a specific path within a document, relying on Typegen for the type.
2944
+ *
2945
+ * @param options - Document options including `documentId`, `documentType`, `path`, and optionally `projectId`/`dataset`.
2946
+ * @returns A stable function to update the value at the specified path. Accepts either the new value or an updater function `(currentValue) => nextValue`.
2947
+ * Returns a promise resolving to the {@link ActionsResult}.
2948
+ */
2949
+ export declare function useEditDocument<
2950
+ TPath extends string = string,
2951
+ TDocumentType extends string = string,
2952
+ TDataset extends string = string,
2953
+ TProjectId extends string = string,
2954
+ >(
2955
+ options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>,
2956
+ ): (
2957
+ nextValue: Updater<
2958
+ JsonMatch<
2959
+ SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>,
2960
+ TPath
2961
+ >
2962
+ >,
2963
+ ) => Promise<
2964
+ ActionsResult<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>>
2965
+ >;
2375
2966
 
2376
2967
  /**
2377
2968
  * @public
2378
2969
  * Edit an entire document with an explicit type `TData`.
2379
2970
  *
2380
- * @param options - Document options including `documentId` and optionally `resource` or `resourceName`.
2971
+ * @param options - Document options including `documentId` and optionally `projectId`/`dataset`.
2381
2972
  * @returns A stable function to update the document state. Accepts either the new document state (`TData`) or an updater function `(currentValue: TData) => nextValue: TData`.
2382
2973
  * Returns a promise resolving to the {@link ActionsResult}.
2383
2974
  */
2384
2975
  export declare function useEditDocument<TData>(
2385
- options: EditDocumentOptions<undefined>,
2386
- ): (nextValue: Updater<TData>) => Promise<ActionsResult>
2976
+ options: DocumentOptions<undefined>,
2977
+ ): (nextValue: Updater<TData>) => Promise<ActionsResult>;
2387
2978
 
2388
2979
  /**
2389
2980
  * @public
2390
2981
  * Edit a specific path within a document with an explicit type `TData`.
2391
2982
  *
2392
- * @param options - Document options including `documentId`, `path`, and optionally `resource` or `resourceName`.
2983
+ * @param options - Document options including `documentId`, `path`, and optionally `projectId`/`dataset`.
2393
2984
  * @returns A stable function to update the value at the specified path. Accepts either the new value (`TData`) or an updater function `(currentValue: TData) => nextValue: TData`.
2394
2985
  * Returns a promise resolving to the {@link ActionsResult}.
2395
2986
  */
2396
2987
  export declare function useEditDocument<TData>(
2397
- options: EditDocumentOptions<string>,
2398
- ): (nextValue: Updater<TData>) => Promise<ActionsResult>
2988
+ options: DocumentOptions<string>,
2989
+ ): (nextValue: Updater<TData>) => Promise<ActionsResult>;
2399
2990
 
2400
2991
  /**
2401
2992
  * @internal
@@ -2403,27 +2994,31 @@ export declare function useEditDocument<TData>(
2403
2994
  export declare function useFrameConnection<
2404
2995
  TFrameMessage extends FrameMessage,
2405
2996
  TWindowMessage extends WindowMessage,
2406
- >(options: UseFrameConnectionOptions<TWindowMessage>): FrameConnection<TFrameMessage>
2997
+ >(
2998
+ options: UseFrameConnectionOptions<TWindowMessage>,
2999
+ ): FrameConnection<TFrameMessage>;
2407
3000
 
2408
3001
  /**
2409
3002
  * @internal
2410
3003
  */
2411
- export declare interface UseFrameConnectionOptions<TWindowMessage extends WindowMessage> {
2412
- name: string
2413
- connectTo: string
2414
- targetOrigin: string
3004
+ export declare interface UseFrameConnectionOptions<
3005
+ TWindowMessage extends WindowMessage,
3006
+ > {
3007
+ name: string;
3008
+ connectTo: string;
3009
+ targetOrigin: string;
2415
3010
  onMessage?: {
2416
- [K in TWindowMessage['type']]: (
3011
+ [K in TWindowMessage["type"]]: (
2417
3012
  data: Extract<
2418
3013
  TWindowMessage,
2419
3014
  {
2420
- type: K
3015
+ type: K;
2421
3016
  }
2422
- >['data'],
2423
- ) => void
2424
- }
2425
- heartbeat?: boolean
2426
- onStatus?: (status: ComlinkStatus) => void
3017
+ >["data"],
3018
+ ) => void;
3019
+ };
3020
+ heartbeat?: boolean;
3021
+ onStatus?: (status: ComlinkStatus) => void;
2427
3022
  }
2428
3023
 
2429
3024
  /**
@@ -2468,19 +3063,57 @@ export declare interface UseFrameConnectionOptions<TWindowMessage extends Window
2468
3063
  */
2469
3064
  export declare const useHandleAuthCallback: () => (
2470
3065
  locationHref?: string | undefined,
2471
- ) => Promise<string | false>
3066
+ ) => Promise<string | false>;
3067
+
3068
+ /**
3069
+ * Returns a single installation by id.
3070
+ *
3071
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
3072
+ * The `include` tokens you pass shape `data`: each requested token adds its
3073
+ * field, and omitted ones are absent from the type.
3074
+ *
3075
+ * @public
3076
+ * @param installationId - The installation id.
3077
+ * @param options - Optional `include` list to expand related resources.
3078
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
3079
+ */
3080
+ export declare const useInstallation: <
3081
+ Include extends InstallationInclude = never,
3082
+ >(
3083
+ installationId: string,
3084
+ options?: {
3085
+ include?: Include[];
3086
+ },
3087
+ ) => FetcherHookResult<Installation<Include>>;
3088
+
3089
+ /**
3090
+ * Returns the installations matching the given options.
3091
+ *
3092
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
3093
+ * The `include` tokens you pass shape `data.data`: each requested token adds its
3094
+ * field, and omitted ones are absent from the type.
3095
+ *
3096
+ * @public
3097
+ * @param options - Filter and include options for the installations list.
3098
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
3099
+ */
3100
+ export declare const useInstallations: <
3101
+ Include extends InstallationInclude = never,
3102
+ >(
3103
+ options: InstallationsOptions<Include>,
3104
+ ) => FetcherHookResult<InstallationsResponse<Include>>;
2472
3105
 
2473
3106
  /**
2474
3107
  * @internal
2475
3108
  */
2476
- export declare function useLoginUrl(): string
3109
+ export declare function useLoginUrl(): string;
2477
3110
 
2478
3111
  /**
2479
3112
  * Hook to log out of the current session
2480
3113
  * @internal
2481
3114
  * @returns A function to log out of the current session
2482
3115
  */
2483
- export declare const useLogOut: () => () => Promise<void>
3116
+ export declare const useLogOut: () => () => Promise<void>;
2484
3117
 
2485
3118
  /**
2486
3119
  * @internal
@@ -2530,20 +3163,22 @@ export declare const useLogOut: () => () => Promise<void>
2530
3163
  export declare function useManageFavorite({
2531
3164
  documentId,
2532
3165
  documentType,
2533
- resource: paramResource,
3166
+ projectId: paramProjectId,
3167
+ dataset: paramDataset,
2534
3168
  resourceId: paramResourceId,
2535
3169
  resourceType,
2536
3170
  schemaName,
2537
- }: UseManageFavoriteProps): ManageFavorite
3171
+ }: UseManageFavoriteProps): ManageFavorite;
2538
3172
 
2539
- declare interface UseManageFavoriteProps extends DocumentHandle {
2540
- resourceId?: string
2541
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
3173
+ declare interface UseManageFavoriteProps extends DocumentHandle_2 {
3174
+ resourceId?: string;
3175
+ resourceType:
3176
+ StudioResource["type"] | MediaResource["type"] | CanvasResource["type"];
2542
3177
  /**
2543
3178
  * The name of the schema collection this document belongs to.
2544
3179
  * Typically is the name of the workspace when used in the context of a studio.
2545
3180
  */
2546
- schemaName?: string
3181
+ schemaName?: string;
2547
3182
  }
2548
3183
 
2549
3184
  /**
@@ -2591,9 +3226,76 @@ declare interface UseManageFavoriteProps extends DocumentHandle {
2591
3226
  * ```
2592
3227
  */
2593
3228
  export declare function useNavigateToStudioDocument(
2594
- documentHandle: DocumentHandle,
3229
+ documentHandle: DocumentHandle_2,
2595
3230
  preferredStudioUrl?: string,
2596
- ): NavigateToStudioResult
3231
+ ): NavigateToStudioResult;
3232
+
3233
+ /**
3234
+ * Returns metadata for a given organisation.
3235
+ *
3236
+ * @category Organizations
3237
+ * @param options - Configuration options
3238
+ * @returns A {@link FetcherHookResult} whose `data` is the metadata for the
3239
+ * organisation. `members` is included only when `includeMembers: true`;
3240
+ * `features` is included only when `includeFeatures: true`.
3241
+ * @example
3242
+ * ```tsx
3243
+ * function OrganizationName({organizationId}: {organizationId: string}) {
3244
+ * const {data: organization} = useOrganization({organizationId})
3245
+ *
3246
+ * return <h1>{organization.name}</h1>
3247
+ * }
3248
+ * ```
3249
+ * @example
3250
+ * ```tsx
3251
+ * const {data: organizationWithMembers} = useOrganization({organizationId, includeMembers: true})
3252
+ * const {data: organizationWithFeatures} = useOrganization({organizationId, includeFeatures: true})
3253
+ * ```
3254
+ * @public
3255
+ * @function
3256
+ */
3257
+ export declare const useOrganization: <
3258
+ IncludeMembers extends boolean = false,
3259
+ IncludeFeatures extends boolean = false,
3260
+ >(
3261
+ options: OrganizationOptions<IncludeMembers, IncludeFeatures>,
3262
+ ) => FetcherHookResult<Organization<IncludeMembers, IncludeFeatures>>;
3263
+
3264
+ /**
3265
+ * Returns metadata for each organisation the current user has access to.
3266
+ *
3267
+ * @category Organizations
3268
+ * @param options - Configuration options
3269
+ * @returns A {@link FetcherHookResult} whose `data` is an array of organisation
3270
+ * metadata. `members` is included only when `includeMembers: true`; `features`
3271
+ * is included only when `includeFeatures: true`.
3272
+ * @example
3273
+ * ```tsx
3274
+ * const {data: organizations} = useOrganizations()
3275
+ *
3276
+ * return (
3277
+ * <select>
3278
+ * {organizations.map((organization) => (
3279
+ * <option key={organization.id}>{organization.name}</option>
3280
+ * ))}
3281
+ * </select>
3282
+ * )
3283
+ * ```
3284
+ * @example
3285
+ * ```tsx
3286
+ * const {data: organizationsWithMembers} = useOrganizations({includeMembers: true})
3287
+ * const {data: organizationsWithFeatures} = useOrganizations({includeFeatures: true})
3288
+ * const {data: organizationsIncludingImplicit} = useOrganizations({includeImplicitMemberships: true})
3289
+ * ```
3290
+ * @public
3291
+ * @function
3292
+ */
3293
+ export declare const useOrganizations: <
3294
+ IncludeMembers extends boolean = false,
3295
+ IncludeFeatures extends boolean = false,
3296
+ >(
3297
+ options?: OrganizationsOptions<IncludeMembers, IncludeFeatures>,
3298
+ ) => FetcherHookResult<Organizations<IncludeMembers, IncludeFeatures>>;
2597
3299
 
2598
3300
  /**
2599
3301
  * Retrieves pages of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,
@@ -2606,16 +3308,18 @@ export declare function useNavigateToStudioDocument(
2606
3308
  * @returns An object containing the list of document handles, pagination details, and functions to navigate between pages
2607
3309
  *
2608
3310
  * @remarks
2609
- * - The returned document handles include resource information from the current Sanity instance
3311
+ * - The returned document handles include projectId and dataset information from the current Sanity instance
2610
3312
  * - This makes them ready to use with document operations and other document hooks
2611
- * - The hook automatically uses the correct Sanity instance based on the resource in the options
3313
+ * - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
2612
3314
  *
2613
3315
  * @example Paginated list of documents with navigation
2614
3316
  * ```tsx
2615
3317
  * import {
2616
3318
  * usePaginatedDocuments,
3319
+ * createDatasetHandle,
3320
+ * type DatasetHandle,
2617
3321
  * type DocumentHandle,
2618
- * type DocumentResource,
3322
+ * type SortOrderingItem,
2619
3323
  * useDocumentProjection
2620
3324
  * } from '@sanity/sdk-react'
2621
3325
  * import {Suspense} from 'react'
@@ -2638,10 +3342,10 @@ export declare function useNavigateToStudioDocument(
2638
3342
  * // Define props for the list component
2639
3343
  * interface PaginatedDocumentListProps {
2640
3344
  * documentType: string
2641
- * resource?: DocumentResource
3345
+ * dataset?: DatasetHandle
2642
3346
  * }
2643
3347
  *
2644
- * function PaginatedDocumentList({documentType, resource}: PaginatedDocumentListProps) {
3348
+ * function PaginatedDocumentList({documentType, dataset}: PaginatedDocumentListProps) {
2645
3349
  * const {
2646
3350
  * data,
2647
3351
  * isPending,
@@ -2652,7 +3356,7 @@ export declare function useNavigateToStudioDocument(
2652
3356
  * hasNextPage,
2653
3357
  * hasPreviousPage
2654
3358
  * } = usePaginatedDocuments({
2655
- * resource,
3359
+ * ...dataset,
2656
3360
  * documentType,
2657
3361
  * pageSize: 10,
2658
3362
  * orderings: [{field: '_createdAt', direction: 'desc'}],
@@ -2684,7 +3388,8 @@ export declare function useNavigateToStudioDocument(
2684
3388
  * }
2685
3389
  *
2686
3390
  * // Usage:
2687
- * // <PaginatedDocumentList resource={{projectId: 'p1', dataset: 'production'}} documentType="post" />
3391
+ * // const myDatasetHandle = createDatasetHandle({ projectId: 'p1', dataset: 'production' })
3392
+ * // <PaginatedDocumentList dataset={myDatasetHandle} documentType="post" />
2688
3393
  * ```
2689
3394
  */
2690
3395
  export declare function usePaginatedDocuments<
@@ -2699,104 +3404,82 @@ export declare function usePaginatedDocuments<
2699
3404
  orderings,
2700
3405
  search,
2701
3406
  ...rawOptions
2702
- }: PaginatedDocumentsOptions<TDocumentType, TDataset, TProjectId>): PaginatedDocumentsResponse<
3407
+ }: PaginatedDocumentsOptions<
2703
3408
  TDocumentType,
2704
3409
  TDataset,
2705
3410
  TProjectId
2706
- >
2707
-
2708
- /**
2709
- * @public
2710
- * @function
2711
- *
2712
- * Returns a single or stack of perspectives for the given perspective handle,
2713
- * which can then be used to correctly query the documents
2714
- * via the `perspective` parameter in the client.
2715
- *
2716
- * @param perspectiveHandle - The perspective handle to get the perspective for.
2717
- * @category Documents
2718
- * @example
2719
- * ```tsx
2720
- * import {usePerspective, useQuery} from '@sanity/sdk-react'
2721
- *
2722
- * const perspective = usePerspective({
2723
- * perspective: 'rxg1346',
2724
- * resource: {projectId: 'abc123', dataset: 'production'},
2725
- * })
2726
- * const {data} = useQuery<Movie[]>({
2727
- * query: '*[_type == "movie"]',
2728
- * perspective,
2729
- * })
2730
- * ```
2731
- *
2732
- * @returns The perspective for the given perspective handle.
2733
- */
2734
- declare type UsePerspective = {
2735
- (perspectiveHandle?: ResourceHandle): string | string[]
2736
- }
3411
+ >): PaginatedDocumentsResponse<TDocumentType, TDataset, TProjectId>;
2737
3412
 
2738
3413
  /**
2739
3414
  * @public
2740
3415
  * @function
2741
3416
  */
2742
- export declare const usePerspective: UsePerspective
3417
+ export declare function usePerspective(
3418
+ perspectiveHandle?: ResourceHandle,
3419
+ ): string | string[];
2743
3420
 
2744
3421
  /**
2745
- * A hook for subscribing to presence information for the current project.
3422
+ * A hook for subscribing to presence information for the current project or Canvas.
2746
3423
  * @public
2747
3424
  */
2748
3425
  export declare function usePresence(options?: ResourceHandle): {
2749
- locations: UserPresence[]
2750
- }
2751
-
2752
- declare type UseProject = {
2753
- /**
2754
- *
2755
- * Returns metadata for a given project
2756
- *
2757
- * @category Projects
2758
- * @param projectHandle - An optional project handle identifying which project to retrieve metadata for
2759
- * @returns The metadata for the project
2760
- * @example
2761
- * ```tsx
2762
- * function ProjectMetadata({ projectId }: { projectId: string }) {
2763
- * const project = useProject({ projectId })
2764
- *
2765
- * return (
2766
- * <figure style={{ backgroundColor: project.metadata.color || 'lavender'}}>
2767
- * <h1>{project.displayName}</h1>
2768
- * </figure>
2769
- * )
2770
- * }
2771
- * ```
2772
- */
2773
- (projectHandle?: ProjectHandle): SanityProject
2774
- }
3426
+ locations: UserPresence[];
3427
+ };
2775
3428
 
2776
3429
  /**
3430
+ * Returns metadata for a given project.
3431
+ *
3432
+ * @category Projects
3433
+ * @param options - Configuration options
3434
+ * @returns A {@link FetcherHookResult} whose `data` is the metadata for the
3435
+ * project. `members` is included only when `includeMembers: true`; `features`
3436
+ * is included unless `includeFeatures: false`.
3437
+ * @example
3438
+ * ```tsx
3439
+ * function ProjectMetadata({projectId}: {projectId: string}) {
3440
+ * const {data: project} = useProject({projectId})
3441
+ *
3442
+ * return (
3443
+ * <figure style={{backgroundColor: project.metadata.color || 'lavender'}}>
3444
+ * <h1>{project.displayName}</h1>
3445
+ * </figure>
3446
+ * )
3447
+ * }
3448
+ * ```
3449
+ * @example
3450
+ * ```tsx
3451
+ * const {data: projectWithMembersAndFeatures} = useProject({projectId})
3452
+ * const {data: projectWithMembers} = useProject({projectId, includeMembers: true})
3453
+ * const {data: projectWithoutMembers} = useProject({projectId, includeMembers: false})
3454
+ * const {data: projectWithoutFeatures} = useProject({projectId, includeFeatures: false})
3455
+ * ```
3456
+ * @remarks
3457
+ * The `projectId` is resolved in order from:
3458
+ * 1. an explicit `projectId` option
3459
+ * 2. A legacy ProjectContext (e.g. a `<ResourceProvider projectId="…">` with no dataset), then
3460
+ * 3. The active resource (`ResourceProvider`/`SDKProvider`)
3461
+ * 4. `instance.config`.
2777
3462
  * @public
2778
3463
  * @function
2779
3464
  */
2780
- export declare const useProject: UseProject
2781
-
2782
- /**
2783
- * @public
2784
- * @category Types
2785
- */
2786
- declare type UseProjects = <TIncludeMembers extends boolean = false>(options?: {
2787
- organizationId?: string
2788
- includeMembers?: TIncludeMembers
2789
- }) => TIncludeMembers extends true ? SanityProject_2[] : ProjectWithoutMembers[]
3465
+ export declare const useProject: <
3466
+ IncludeMembers extends boolean = true,
3467
+ IncludeFeatures extends boolean = true,
3468
+ >(
3469
+ options?: ProjectOptions<IncludeMembers, IncludeFeatures>,
3470
+ ) => FetcherHookResult<Project<IncludeMembers, IncludeFeatures>>;
2790
3471
 
2791
3472
  /**
2792
3473
  * Returns metadata for each project you have access to.
2793
3474
  *
2794
3475
  * @category Projects
2795
3476
  * @param options - Configuration options
2796
- * @returns An array of project metadata. If includeMembers is true, returns full SanityProject objects. Otherwise, returns ProjectWithoutMembers objects.
3477
+ * @returns A {@link FetcherHookResult} whose `data` is an array of project
3478
+ * metadata. `members` is included only when `includeMembers: true`; `features`
3479
+ * is included unless `includeFeatures: false`.
2797
3480
  * @example
2798
3481
  * ```tsx
2799
- * const projects = useProjects()
3482
+ * const {data: projects} = useProjects()
2800
3483
  *
2801
3484
  * return (
2802
3485
  * <select>
@@ -2808,19 +3491,95 @@ declare type UseProjects = <TIncludeMembers extends boolean = false>(options?: {
2808
3491
  * ```
2809
3492
  * @example
2810
3493
  * ```tsx
2811
- * const projectsWithMembers = useProjects({ includeMembers: true })
2812
- * const projectsWithoutMembers = useProjects({ includeMembers: false })
3494
+ * const {data: projects} = useProjects()
3495
+ * const {data: projectsWithFeatures} = useProjects()
3496
+ * const {data: projectsWithMembers} = useProjects({includeMembers: true})
3497
+ * const {data: projectsWithoutMembers} = useProjects({includeMembers: false})
3498
+ * const {data: projectsWithoutFeatures} = useProjects({includeFeatures: false})
2813
3499
  * ```
2814
3500
  * @public
2815
3501
  * @function
2816
3502
  */
2817
- export declare const useProjects: UseProjects
3503
+ export declare const useProjects: <
3504
+ IncludeMembers extends boolean = false,
3505
+ IncludeFeatures extends boolean = true,
3506
+ >(
3507
+ options?: ProjectsOptions<IncludeMembers, IncludeFeatures>,
3508
+ ) => FetcherHookResult<Project<IncludeMembers, IncludeFeatures>[]>;
3509
+
3510
+ /**
3511
+ * @public
3512
+ * Executes a GROQ query, inferring the result type from the query string and options.
3513
+ * Leverages Sanity Typegen if configured for enhanced type safety.
3514
+ *
3515
+ * @param options - Configuration for the query, including `query`, optional `params`, `projectId`, `dataset`, etc.
3516
+ * @returns An object containing `data` (typed based on the query) and `isPending` (for transitions).
3517
+ *
3518
+ * @example Basic usage (Inferred Type)
3519
+ * ```tsx
3520
+ * import {useQuery} from '@sanity/sdk-react'
3521
+ * import {defineQuery} from 'groq'
3522
+ *
3523
+ * const myQuery = defineQuery(`*[_type == "movie"]{_id, title}`)
3524
+ *
3525
+ * function MovieList() {
3526
+ * // Typegen infers the return type for data
3527
+ * const {data} = useQuery({ query: myQuery })
3528
+ *
3529
+ * return (
3530
+ * <div>
3531
+ * <h2>Movies</h2>
3532
+ * <ul>
3533
+ * {data.map(movie => <li key={movie._id}>{movie.title}</li>)}
3534
+ * </ul>
3535
+ * </div>
3536
+ * )
3537
+ * }
3538
+ * // Suspense boundary should wrap <MovieList /> for initial load
3539
+ * ```
3540
+ *
3541
+ * @example Using parameters (Inferred Type)
3542
+ * ```tsx
3543
+ * import {useQuery} from '@sanity/sdk-react'
3544
+ * import {defineQuery} from 'groq'
3545
+ *
3546
+ * const myQuery = defineQuery(`*[_type == "movie" && _id == $id][0]`)
3547
+ *
3548
+ * function MovieDetails({movieId}: {movieId: string}) {
3549
+ * // Typegen infers the return type based on query and params
3550
+ * const {data, isPending} = useQuery({
3551
+ * query: myQuery,
3552
+ * params: { id: movieId }
3553
+ * })
3554
+ *
3555
+ * return (
3556
+ * // utilize `isPending` to signal to users that new data is coming in
3557
+ * // (e.g. the `movieId` changed and we're loading in the new one)
3558
+ * <div style={{ opacity: isPending ? 0.5 : 1 }}>
3559
+ * {data ? <h1>{data.title}</h1> : <p>Movie not found</p>}
3560
+ * </div>
3561
+ * )
3562
+ * }
3563
+ * ```
3564
+ */
3565
+ export declare function useQuery<
3566
+ TQuery extends string = string,
3567
+ TDataset extends string = string,
3568
+ TProjectId extends string = string,
3569
+ >(
3570
+ options: UseQueryOptions<TQuery, TDataset, TProjectId>,
3571
+ ): {
3572
+ /** The query result, typed based on the GROQ query string */
3573
+ data: SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`>;
3574
+ /** True if a query transition is in progress */
3575
+ isPending: boolean;
3576
+ };
2818
3577
 
2819
3578
  /**
2820
3579
  * @public
2821
3580
  * Executes a GROQ query with an explicitly provided result type `TData`.
2822
3581
  *
2823
- * @param options - Configuration for the query, including `query`, optional `params`, `resource`, etc.
3582
+ * @param options - Configuration for the query, including `query`, optional `params`, `projectId`, `dataset`, etc.
2824
3583
  * @returns An object containing `data` (cast to `TData`) and `isPending` (indicates whether a query resolution is pending; note that Suspense handles initial loading states). *
2825
3584
  * @example Manually typed query result
2826
3585
  * ```tsx
@@ -2844,12 +3603,24 @@ export declare const useProjects: UseProjects
2844
3603
  * }
2845
3604
  * ```
2846
3605
  */
2847
- export declare function useQuery<TData>(options: ReactQueryOptions): {
3606
+ export declare function useQuery<TData>(
3607
+ options: WithResourceNameSupport<QueryOptions>,
3608
+ ): {
2848
3609
  /** The query result, cast to the provided type TData */
2849
- data: TData
3610
+ data: TData;
2850
3611
  /** True if another query is resolving in the background (suspense handles the initial loading state) */
2851
- isPending: boolean
2852
- }
3612
+ isPending: boolean;
3613
+ };
3614
+
3615
+ /**
3616
+ * Hook options for useQuery, supporting both direct resource and resourceName.
3617
+ * @beta
3618
+ */
3619
+ declare type UseQueryOptions<
3620
+ TQuery extends string = string,
3621
+ TDataset extends string = string,
3622
+ TProjectId extends string = string,
3623
+ > = WithResourceNameSupport<QueryOptions<TQuery, TDataset, TProjectId>>;
2853
3624
 
2854
3625
  /**
2855
3626
  * @internal
@@ -2898,44 +3669,40 @@ export declare function useRecordDocumentHistoryEvent({
2898
3669
  resourceType,
2899
3670
  resourceId,
2900
3671
  schemaName,
2901
- }: UseRecordDocumentHistoryEventProps): DocumentInteractionHistory
3672
+ }: UseRecordDocumentHistoryEventProps): DocumentInteractionHistory;
2902
3673
 
2903
3674
  /**
2904
3675
  * @internal
2905
3676
  */
2906
- declare interface UseRecordDocumentHistoryEventProps extends DocumentHandle {
2907
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
2908
- resourceId?: string
3677
+ declare interface UseRecordDocumentHistoryEventProps extends DocumentHandle_2 {
3678
+ resourceType:
3679
+ StudioResource["type"] | MediaResource["type"] | CanvasResource["type"];
3680
+ resourceId?: string;
2909
3681
  /**
2910
3682
  * The name of the schema collection this document belongs to.
2911
3683
  * Typically is the name of the workspace when used in the context of a studio.
2912
3684
  */
2913
- schemaName?: string
3685
+ schemaName?: string;
2914
3686
  }
2915
3687
 
2916
3688
  /**
2917
- * Returns the current {@link DocumentResource} from context.
3689
+ * Returns the currently active `DocumentResource` for the nearest resource context.
2918
3690
  *
2919
- * @public
3691
+ * Resolves in priority order:
3692
+ * 1. A `resource` prop on the nearest `<ResourceProvider>`
3693
+ * 2. The `projectId`/`dataset` from the current `SanityInstance` config
3694
+ * 3. `undefined` when neither is available
2920
3695
  *
3696
+ * @public
2921
3697
  * @category Platform
2922
- * @returns The resource set by the nearest `ResourceProvider`, or `undefined`
2923
3698
  *
2924
- * @remarks
2925
- * With the flat instance model, nested `ResourceProvider`s override the
2926
- * active resource via React context rather than creating child instances.
2927
- * Use this hook when you need the current project/dataset/resource for a
2928
- * subtree instead of reading from `useSanityInstance().config`.
2929
- *
2930
- * @example Get the current resource
3699
+ * @example
2931
3700
  * ```tsx
2932
3701
  * const resource = useResource()
2933
- * if (resource && 'projectId' in resource) {
2934
- * console.log(resource.projectId, resource.dataset)
2935
- * }
3702
+ * console.log(resource?.projectId, resource?.dataset)
2936
3703
  * ```
2937
3704
  */
2938
- export declare function useResource(): DocumentResource | undefined
3705
+ export declare function useResource(): DocumentResource | undefined;
2939
3706
 
2940
3707
  /**
2941
3708
  * @public
@@ -2945,11 +3712,11 @@ export declare interface UserResult {
2945
3712
  /**
2946
3713
  * The user data fetched, or undefined if not found.
2947
3714
  */
2948
- data: SanityUser | undefined
3715
+ data: SanityUser | undefined;
2949
3716
  /**
2950
3717
  * Whether a user request is currently in progress
2951
3718
  */
2952
- isPending: boolean
3719
+ isPending: boolean;
2953
3720
  }
2954
3721
 
2955
3722
  /**
@@ -2960,42 +3727,49 @@ export declare interface UsersResult {
2960
3727
  /**
2961
3728
  * The users fetched.
2962
3729
  */
2963
- data: SanityUser[]
3730
+ data: SanityUser[];
2964
3731
  /**
2965
3732
  * Whether there are more users to fetch.
2966
3733
  */
2967
- hasMore: boolean
3734
+ hasMore: boolean;
2968
3735
  /**
2969
3736
  * Whether a users request is currently in progress
2970
3737
  */
2971
- isPending: boolean
3738
+ isPending: boolean;
2972
3739
  /**
2973
3740
  * Load more users.
2974
3741
  */
2975
- loadMore: () => void
3742
+ loadMore: () => void;
2976
3743
  }
2977
3744
 
2978
3745
  /**
2979
- * Retrieves the current Sanity instance from React context.
3746
+ * Retrieves the current Sanity instance from context
2980
3747
  *
2981
3748
  * @public
2982
3749
  *
2983
3750
  * @category Platform
2984
- * @returns The current instance
3751
+ * @param config - Deprecated. Formerly used to match against the instance hierarchy.
3752
+ * @returns The current Sanity instance
2985
3753
  *
2986
3754
  * @remarks
2987
- * This hook accesses the nearest Sanity instance from React context,
2988
- * provided by a `ResourceProvider` or `SanityApp`.
3755
+ * This hook accesses the nearest Sanity instance from the React context.
3756
+ * The hook must be used within a component wrapped by a `ResourceProvider` or `SanityApp`.
2989
3757
  *
2990
3758
  * @example Get the current instance
2991
3759
  * ```tsx
2992
3760
  * const instance = useSanityInstance()
2993
- * console.log(instance.config)
3761
+ * console.log(instance.config.projectId)
2994
3762
  * ```
2995
3763
  *
2996
3764
  * @throws Error if no SanityInstance is found in context
2997
3765
  */
2998
- export declare const useSanityInstance: () => SanityInstance
3766
+ export declare const useSanityInstance: (
3767
+ /**
3768
+ * @deprecated Passing a config to match against the instance hierarchy is deprecated.
3769
+ * Use `useSanityInstance()` without arguments instead.
3770
+ */
3771
+ config?: SanityConfig,
3772
+ ) => SanityInstance;
2999
3773
 
3000
3774
  /**
3001
3775
  * Hook that fetches studio workspaces and organizes them by projectId:dataset
@@ -3031,7 +3805,29 @@ export declare const useSanityInstance: () => SanityInstance
3031
3805
  * }
3032
3806
  * ```
3033
3807
  */
3034
- export declare function useStudioWorkspacesByProjectIdDataset(): StudioWorkspacesResult
3808
+ export declare function useStudioWorkspacesByProjectIdDataset(): StudioWorkspacesResult;
3809
+
3810
+ /**
3811
+ * Updates an application's mutable properties (title, icon, visibility).
3812
+ *
3813
+ * @internal
3814
+ * @returns The mutation envelope `{mutate, isPending, error, data, reset}`.
3815
+ */
3816
+ export declare const useUpdateApplication: () => MutationHookResult<
3817
+ UpdateApplicationInput,
3818
+ ApplicationBase
3819
+ >;
3820
+
3821
+ /**
3822
+ * Updates a user application.
3823
+ *
3824
+ * @internal
3825
+ * @returns The mutation envelope `{mutate, isPending, error, data, reset}`.
3826
+ */
3827
+ export declare const useUpdateUserApplication: () => MutationHookResult<
3828
+ UpdateUserApplicationInput,
3829
+ UserApplication
3830
+ >;
3035
3831
 
3036
3832
  /**
3037
3833
  *
@@ -3065,7 +3861,33 @@ export declare function useStudioWorkspacesByProjectIdDataset(): StudioWorkspace
3065
3861
  * )
3066
3862
  * ```
3067
3863
  */
3068
- export declare function useUser(options: GetUserOptions): UserResult
3864
+ export declare function useUser(options: GetUserOptions): UserResult;
3865
+
3866
+ /**
3867
+ * Returns a single user application by id.
3868
+ *
3869
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
3870
+ *
3871
+ * @public
3872
+ * @param userApplicationId - The user application id.
3873
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
3874
+ */
3875
+ export declare const useUserApplication: (
3876
+ userApplicationId: string,
3877
+ ) => FetcherHookResult<UserApplication>;
3878
+
3879
+ /**
3880
+ * Returns the current user's applications for the given organisation.
3881
+ *
3882
+ * The hook suspends until the first fetch succeeds, so `data` is always present.
3883
+ *
3884
+ * @public
3885
+ * @param options - Options identifying the organisation.
3886
+ * @returns The result envelope `{data, isFetching, error, refetch}`.
3887
+ */
3888
+ export declare const useUserApplications: (
3889
+ options: UserApplicationsOptions,
3890
+ ) => FetcherHookResult<UserApplication[]>;
3069
3891
 
3070
3892
  /**
3071
3893
  *
@@ -3098,8 +3920,14 @@ export declare function useUser(options: GetUserOptions): UserResult
3098
3920
  * </div>
3099
3921
  * )
3100
3922
  * ```
3923
+ * @remarks
3924
+ * For project-scoped queries the `projectId` is resolved in order from:
3925
+ * 1. an explicit `projectId` option
3926
+ * 2. A legacy ProjectContext (e.g. a `<ResourceProvider projectId="…">` with no dataset), then
3927
+ * 3. The active resource (`ResourceProvider`/`SDKProvider`)
3928
+ * 4. `instance.config`.
3101
3929
  */
3102
- export declare function useUsers(options?: GetUsersOptions): UsersResult
3930
+ export declare function useUsers(options?: GetUsersOptions): UsersResult;
3103
3931
 
3104
3932
  /**
3105
3933
  * Hook that verifies the current projects belongs to the organization ID specified in the dashboard context.
@@ -3124,7 +3952,7 @@ export declare function useUsers(options?: GetUsersOptions): UsersResult
3124
3952
  export declare function useVerifyOrgProjects(
3125
3953
  disabled?: boolean,
3126
3954
  projectIds?: string[],
3127
- ): string | null
3955
+ ): string | null;
3128
3956
 
3129
3957
  /**
3130
3958
  * @internal
@@ -3142,68 +3970,122 @@ export declare function useWindowConnection<
3142
3970
  name,
3143
3971
  connectTo,
3144
3972
  onMessage,
3145
- }: UseWindowConnectionOptions<TFrameMessage>): WindowConnection<TWindowMessage>
3973
+ }: UseWindowConnectionOptions<TFrameMessage>): WindowConnection<TWindowMessage>;
3146
3974
 
3147
3975
  /**
3148
3976
  * @internal
3149
3977
  */
3150
- export declare interface UseWindowConnectionOptions<TMessage extends FrameMessage> {
3151
- name: string
3152
- connectTo: string
3153
- onMessage?: Record<TMessage['type'], WindowMessageHandler<TMessage>>
3978
+ export declare interface UseWindowConnectionOptions<
3979
+ TMessage extends FrameMessage,
3980
+ > {
3981
+ name: string;
3982
+ connectTo: string;
3983
+ onMessage?: Record<TMessage["type"], WindowMessageHandler<TMessage>>;
3154
3984
  }
3155
3985
 
3986
+ /**
3987
+ * Sets the browser's document title, automatically including the app's name
3988
+ * from the manifest.
3989
+ *
3990
+ * This follows the same convention as Sanity Studio workspaces, where the
3991
+ * workspace name is always present in the title:
3992
+ *
3993
+ * - With a view title: `<viewTitle> | <appTitle>`
3994
+ * - Without a view title: `<appTitle>`
3995
+ *
3996
+ * The Sanity dashboard appends `| Sanity` to produce the final browser tab title.
3997
+ *
3998
+ * @param viewTitle - An optional view-specific title to prepend to the app title.
3999
+ *
4000
+ * @example
4001
+ * ```tsx
4002
+ * import {useWindowTitle} from '@sanity/sdk-react'
4003
+ *
4004
+ * function MoviesList() {
4005
+ * useWindowTitle('Movies')
4006
+ * return <div>...</div>
4007
+ * }
4008
+ *
4009
+ * // Browser tab: "Movies | My App | Sanity"
4010
+ * ```
4011
+ *
4012
+ * @example
4013
+ * ```tsx
4014
+ * // Call without arguments to show just the app title
4015
+ * function AppRoot() {
4016
+ * useWindowTitle()
4017
+ * return <Outlet />
4018
+ * }
4019
+ *
4020
+ * // Browser tab: "My App | Sanity"
4021
+ * ```
4022
+ *
4023
+ * @public
4024
+ */
4025
+ export declare function useWindowTitle(viewTitle?: string): void;
4026
+
3156
4027
  /**
3157
4028
  * @internal
3158
4029
  */
3159
4030
  export declare interface WindowConnection<TMessage extends WindowMessage> {
3160
- sendMessage: <TType extends TMessage['type']>(
4031
+ sendMessage: <TType extends TMessage["type"]>(
3161
4032
  type: TType,
3162
4033
  data?: Extract<
3163
4034
  TMessage,
3164
4035
  {
3165
- type: TType
4036
+ type: TType;
3166
4037
  }
3167
- >['data'],
3168
- ) => void
4038
+ >["data"],
4039
+ ) => void;
3169
4040
  fetch: <TResponse>(
3170
4041
  type: string,
3171
4042
  data?: MessageData,
3172
4043
  options?: {
3173
- signal?: AbortSignal
3174
- suppressWarnings?: boolean
3175
- responseTimeout?: number
4044
+ signal?: AbortSignal;
4045
+ suppressWarnings?: boolean;
4046
+ responseTimeout?: number;
3176
4047
  },
3177
- ) => Promise<TResponse>
4048
+ ) => Promise<TResponse>;
3178
4049
  }
3179
4050
 
3180
4051
  /**
3181
4052
  * @internal
3182
4053
  */
3183
4054
  export declare type WindowMessageHandler<TFrameMessage extends FrameMessage> = (
3184
- event: TFrameMessage['data'],
3185
- ) => TFrameMessage['response']
4055
+ event: TFrameMessage["data"],
4056
+ ) => TFrameMessage["response"];
3186
4057
 
3187
4058
  /**
3188
- * You should generally prefer to use the React-layer handle types (ResourceHandle, DocumentHandle) from '\@sanity/sdk-react' instead.
3189
- * This type is useful for non-handles (like document actions) that we still want to resolve resources for.
3190
4059
  * Adds React hook support (resourceName resolution) to core types.
3191
- * @internal
4060
+ * Prefer using the React-layer handle types (ResourceHandle, DocumentHandle)
4061
+ * from `@sanity/sdk-react` — this wrapper is kept for cases where overloads
4062
+ * don't fit (e.g. non-handle options objects).
4063
+ *
4064
+ * @typeParam T - The core type to extend (must have optional `resource` field)
4065
+ * @beta
3192
4066
  */
3193
- declare type WithResourceNameSupport<T> = Omit<T, 'resource'> & {
3194
- resource?: DocumentResource
4067
+ declare type WithResourceNameSupport<
4068
+ T extends {
4069
+ resource?: DocumentResource;
4070
+ },
4071
+ > = T & {
3195
4072
  /**
3196
4073
  * Optional name of a resource to resolve from context.
3197
4074
  * If provided, will be resolved to a `DocumentResource` via `ResourcesContext`.
3198
4075
  * @beta
3199
4076
  */
3200
- resourceName?: string
3201
- }
4077
+ resourceName?: string;
4078
+ /**
4079
+ * @deprecated Use `resourceName` instead.
4080
+ * @beta
4081
+ */
4082
+ sourceName?: string;
4083
+ };
3202
4084
 
3203
4085
  declare interface WorkspacesByProjectIdDataset {
3204
- [key: `${string}:${string}`]: DashboardResource[]
4086
+ [key: `${string}:${string}`]: DashboardResource[];
3205
4087
  }
3206
4088
 
3207
- export * from '@sanity/sdk'
4089
+ export * from "@sanity/sdk";
3208
4090
 
3209
- export {}
4091
+ export {};