Skip to main content
userTourKit
@tour-kit/announcementsHooks

useAnnouncementsContext

Low-level hook returning the raw AnnouncementsProvider context — registered announcements, queue, queue config, and the full action surface

domidex01Published Updated

Low-level access to the raw AnnouncementsContext. Most consumers should use useAnnouncement or useAnnouncementsuseAnnouncementsContext is the escape hatch when you need everything at once (queue dashboards, debug panels, custom orchestration).

useAnnouncementsContext throws if no <AnnouncementsProvider> is mounted above.

Usage

import { useAnnouncementsContext } from '@tour-kit/announcements';

function QueueDebugger() {
  const { announcements, activeAnnouncement, queue, clearQueue } = useAnnouncementsContext();
  return (
    <aside>
      <p>Active: {activeAnnouncement ?? 'none'}</p>
      <p>Queue length: {queue.length}</p>
      <button onClick={clearQueue}>Clear queue</button>
    </aside>
  );
}

Return Value

FieldTypeDescription
announcementsMap<string, AnnouncementState>All registered announcements
activeAnnouncementstring | nullCurrently visible announcement id
queuestring[]Pending announcement ids
queueConfigQueueConfigResolved queue configuration
register(config) => voidRegister a new announcement
unregister(id) => voidRemove an announcement
show(id) => voidShow or queue an announcement
hide(id) => voidTemporarily hide
dismiss(id, reason?) => voidPersist dismissal
complete(id) => voidMark primary action taken
reset(id) => voidReset a dismissed announcement
resetAll() => voidReset every dismissed announcement
getState(id) => AnnouncementState | undefinedRead state
getConfig(id) => AnnouncementConfig | undefinedRead config
canShow(id) => booleanFrequency/schedule/audience evaluation
showNext() => voidPop next from the queue
clearQueue() => voidDrop all queued announcements

For typical flows, prefer useAnnouncement for single-announcement control or useAnnouncementQueue for queue inspection.

On this page