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

Low-level access to the raw AnnouncementsContext. Most consumers should use useAnnouncement or useAnnouncements — useAnnouncementsContext 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.

Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is free while you build. Every package works unlicensed in development, a one-time licence from $9.99 removes the production watermark when you ship.

Free in development, no signup, no credit card. Pay once, only when you ship.

On this page