Skip to main content
Custom blocks are in private alpha:
  • Do not discuss publicly or share with anyone outside your workspace.
  • Access must be enabled per workspace. Installing the SDK does not grant access.
  • These APIs may experience breaking changes without notice.

The current user

customBlock.getCurrentUser() and useCurrentUser() return the user viewing the custom block. Both read the user from the block’s state without a separate request. Wait for initCustomBlock() to resolve before calling the getter or mounting components that use the hook. See initialization.

TypeScript API

Use customBlock.getCurrentUser() to read the current user in any framework. Subscribe to context changes to keep your UI updated:
Call unsubscribe() when you no longer need updates. The callback can run even when the current user has not changed.

React hook

In React, use useCurrentUser() to re-render when the current user changes:
Both approaches return the same NotionUser shape.

User object

NotionUser is based on the public API User object. users.get() and the current-user APIs return a NotionUser. users.list() returns a page of these objects. Custom blocks return only people, not bots or integrations. All fields except name are always present. name may be omitted. avatar_url is present but can be null.

List users

Each users.list() call returns one page of workspace users visible to the viewing user. The SDK does not fetch the remaining pages automatically.
Pass next_cursor as startCursor to request the next page. Use the cursor exactly as returned. Do not parse it or create your own. Stop when has_more is false.

Get a user

On success, result.user is a NotionUser. A people property can contain both users and groups (object: "group"). users.get() and users.list() only support people. You cannot use these APIs to resolve a group or list its members. Skip group entries when you need a person’s name and avatar. Match the person’s ID against results from users.list(). Reuse those results if your UI already lists workspace users. IDs in a people property are plain strings. users.get() requires a NotionUserId, such as an ID from the user APIs.

Permissions

A user returned by users.list() does not necessarily have access to the current page or data source. Do not use this list to check page or data source permissions. If a request returns status: "error", handle the error before reading result.user or result.list. See error handling.