Sanity React App SDK v2.11.0: New organization hooks and expanded useProjects options

This release adds two new React hooks for working with organization metadata, expands the parameter options on the projects store, and moves the SDK to a single shared Sanity instance.

New hooks for organization metadata

Use useOrganization to get metadata for a single organization. Pass includeMembers: true to include members, or includeFeatures: true to include features.

function OrganizationName({organizationId}: {organizationId: string}) {
const organization = useOrganization({organizationId})

return {organization.name}
}

const organizationWithMembers = useOrganization({organizationId, includeMembers: true})
const organizationWithFeatures = useOrganization({organizationId, includeFeatures: true})

Use useOrganizations to get metadata for every organization the current user can access.

const organizations = useOrganizations()

return (

{organizations.map((organization) => (
{organization.name}
))}

)

useOrganizations accepts the same options, plus includeImplicitMemberships.

const organizationsWithMembers = useOrganizations({includeMembers: true})
const organizationsWithFeatures = useOrganizations({includeFeatures: true})
const organizationsIncludingImplicit = useOrganizations({includeImplicitMemberships: true})

Both hooks support suspense. The release also exports new public types: Organization, OrganizationBase, OrganizationMember, and OrganizationsOptions.

More options on useProjects

The useProjects hook now accepts includeFeatures, onlyExplicitMembership, and organizationId as typed options. Use organizationId to scope results to a single organization, onlyExplicitMembership to exclude implicit memberships, and includeFeatures to include feature data on each project.

This release also exports new public types: Project, ProjectBase, ProjectMember, ProjectMemberRole, ProjectMetadata, and ProjectsOptions.

Single Sanity instance

The SDK now uses one shared Sanity instance internally.