Sanity App SDK
    Preparing search index...
    • Retrieves the users for a given resource (either a project or an organization).

      Parameters

      Returns UsersResult

      A list of users, a boolean indicating whether there are more users to fetch, and a function to load more users

      const { data, hasMore, loadMore, isPending } = useUsers({
      resourceType: 'organization',
      organizationId: 'my-org-id',
      batchSize: 10,
      })

      return (
      <div>
      {data.map(user => (
      <figure key={user.sanityUserId}>
      <img src={user.profile.imageUrl} alt='' />
      <figcaption>{user.profile.displayName}</figcaption>
      <address>{user.profile.email}</address>
      </figure>
      ))}
      {hasMore && <button onClick={loadMore}>{isPending ? 'Loading...' : 'Load More'</button>}
      </div>
      )