NotionCustomBlock
NotionCustomBlock runs the handshake. It renders its children after initialization succeeds. Wrap your application in NotionCustomBlock.
NotionTokenScope, contrast mode, and sizing are covered in appearance and sizing.
NotionCustomBlock handles NotInIframeError separately. See error handling for this exception.
useCustomBlockInit
The one hook safe to call before initialization. Use it when you need to render your own loading and error states outside NotionCustomBlock.
{ isLoaded: false, error: undefined } while in flight, { isLoaded: false, error } on failure, and { isLoaded: true, error: undefined, initial } on success, where initial is the full init payload.
Every other hook must be called inside NotionCustomBlock, because they throw if the block is not yet initialized.
initCustomBlock
Outside React, initCustomBlock() performs the handshake and resolves with the block’s context. Calling it more than once returns the same promise.
customBlock object — see app context.
Await initCustomBlock() before calling context getters. Context subscriptions can be registered earlier and wait for initialization before delivering the initial value.
Initialization errors
initCustomBlock() and useCustomBlockInit() report initialization failures as a CustomBlockInitializationError. This error contains code, message, and isRetryable.
See error handling for the full set of codes.