Realtime Visitors

1 个变体

A live analytics panel with a rolling visitor count, a dotted world map of visitor pings, and a ranked list of active pages.

Live visitors

A live visitor panel with a rolling count, a change pill, and per-minute bars, a dotted world map that pings at visitor cities, a Pages, Referrers, and Countries list that reorders as counts change, and a stream of latest arrivals that lights each visitor's city on hover.

Right now

Paused
124visitors online29%vs 30 min ago
30 min agoNow
PagesVisitors
  • /31
  • /pricing22
  • /docs/getting-started18
  • /blog/edge-caching15
  • /changelog12

Latest arrivals

  • DEBerlin/pricing from google.comnow
  • INBengaluru/docs/getting-started from github.com14s
  • USSan Francisco/ from news.ycombinator.com27s
"use client";

import { RealtimeVisitors } from "@/components/premium/realtime-visitors";

export function RealtimeVisitorsLivePreview() {
  return (
    <div className="w-full px-4 py-10">
      <RealtimeVisitors />
    </div>
  );
}

安装

$ bunx --bun shadcn add @beui-pro/realtime-visitors-live

API 参考

除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。

RealtimeVisitors19 个属性
  • cities

    Cities with their starting visitors; their sum is the starting live count.

    RealtimeCity[]
  • pages

    Pages with their starting visitors.

    RealtimeRow[]
  • referrers

    Referrers with their starting visitors.

    RealtimeRow[]
  • minutes

    Live count at the end of each of the last minutes, oldest first.

    number[]
  • events

    Arrivals on screen at mount, newest first.

    RealtimeEvent[]
  • maxEvents

    Most arrivals shown under the list. Set 0 to hide them.

    number

    默认值 3

  • live

    Simulate arrivals and departures. Set false to show the data as given.

    boolean

    默认值 true

  • intervalMs

    Time between simulated arrivals or departures, in ms.

    number

    默认值 1600

  • ticksPerMinute

    Ticks that make one simulated minute on the bars.

    number

    默认值 6

  • maxRows

    Most rows in the list.

    number

    默认值 5

  • tab

    Controlled list tab.

    "pages" | "referrers" | "countries"
  • defaultTab

    List tab when uncontrolled.

    "pages" | "referrers" | "countries"

    默认值 pages

  • onTabChange

    Called when a list tab is chosen.

    ((tab: RealtimeTab) => void)
  • accentColor

    Map marker and ping color. Any CSS color.

    string

    默认值 #10b981

  • accentClassName

    Live dot and newest bar color class.

    string

    默认值 bg-emerald-500

  • barClassNames

    List share bar color class for each tab; any tab left out keeps its default.

    Partial<Record<RealtimeTab, string>>
  • formatValue

    Formats visitor counts in the map tooltip.

    ((value: number) => string)

    默认值 (value: number) => numberFormat.format(value)

  • labels

    Copy overrides; anything left out uses the English defaults.

    Partial<RealtimeVisitorsLabels>
  • className

    Classes merged onto the root element.

    string
ActiveList8 个属性
  • rows必填

    Rows per tab.

    Record<RealtimeTab, RealtimeRow[]>
  • tab必填

    Selected tab.

    "pages" | "referrers" | "countries"
  • onTabChange必填

    Called when a tab is chosen.

    (tab: RealtimeTab) => void
  • maxRows必填

    Most rows shown at once.

    number
  • reduce必填

    Skip movement, keep fades.

    boolean
  • labels必填

    Copy for tabs, headings and the empty state.

    RealtimeVisitorsLabels
  • barClassNames必填

    Share bar color class for each tab.

    Record<RealtimeTab, string>
  • onPauseChange必填

    Called with true while the pointer or focus is in the list, to pause the feed.

    (paused: boolean) => void
ActiveRow7 个属性
  • row必填

    The row to draw.

    RealtimeRow
  • tab必填

    Which list the row belongs to; pages render the label in mono.

    "pages" | "referrers" | "countries"
  • share必填

    Bar width as a share of the largest row, 0 to 1.

    number
  • delay必填

    Entrance delay in seconds; 0 for rows that arrive after mount.

    number
  • reduce必填

    Skip movement, keep fades.

    boolean
  • barClassName必填

    Share bar color class, such as `bg-emerald-500/15`.

    string
  • ref

    The row element, so AnimatePresence can pop exiting rows out of the flow.

    Ref<HTMLLIElement>
ActivityFeed9 个属性
  • events必填

    Arrivals, newest first.

    RealtimeEvent[]
  • clock必填

    Feed seconds now, used to age each arrival.

    number
  • maxEvents必填

    Rows kept on screen; the list holds this height so nothing below jumps.

    number
  • activeCityId必填

    City id lit on the map, so its rows read as selected.

    string | null
  • onActiveCityChange必填

    Called with a city id while a row is hovered, and null when it leaves.

    (cityId: string | null) => void
  • reduce必填

    Skip movement, keep fades.

    boolean
  • labels必填

    Copy for the heading, ages and the page/referrer joiner.

    RealtimeVisitorsLabels
  • accentClassName必填

    Dot color class for the newest arrival, such as `bg-emerald-500`.

    string
  • onPauseChange

    Called with true while the pointer is over the arrivals, so rows hold still to be read.

    ((paused: boolean) => void)
DeltaPill4 个属性
  • from必填

    Earlier value to compare against.

    number
  • to必填

    Current value.

    number
  • suffix必填

    Text after the pill, such as "vs 30 min ago".

    string
  • className

    Classes merged onto the root element.

    string
LiveHeader7 个属性
  • total必填

    Visitors online now.

    number
  • minutes必填

    Per-minute values for the bars, with one off-screen bar on the left.

    number[]
  • minuteTick必填

    Increments on each new minute.

    number
  • running必填

    True while the feed is running; drives the dot's pulse and status text.

    boolean
  • reduce必填

    Skip loops and movement.

    boolean
  • labels必填

    Copy for the title, status and captions.

    RealtimeVisitorsLabels
  • accentClassName必填

    Live dot and newest bar color class, such as `bg-emerald-500`.

    string
MinuteBars7 个属性
  • values必填

    Per-minute values, oldest first, with one extra bar on the left that sits off-screen.

    number[]
  • tick必填

    Increments when a new minute rolls in; replays the slide.

    number
  • reduce必填

    Skip the slide and growth animations.

    boolean
  • barClassName

    Class for the newest bar, such as `bg-emerald-500`.

    string

    默认值 bg-emerald-500

  • restClassName

    Class for the older bars.

    string

    默认值 bg-foreground/30

  • label必填

    Accessible summary of the chart.

    string
  • className

    Classes merged onto the root element.

    string
useVisitorFeed9 个属性
  • cities必填

    Cities with their starting visitors.

    RealtimeCity[]
  • pages必填

    Pages with their starting visitors.

    RealtimeRow[]
  • referrers必填

    Referrers with their starting visitors.

    RealtimeRow[]
  • minutes必填

    Live count at the end of each past minute, oldest first.

    number[]
  • events必填

    Arrivals already on screen, newest first.

    RealtimeEvent[]
  • maxEvents必填

    Most arrivals kept.

    number
  • active必填

    Run the simulation only while true.

    boolean
  • intervalMs必填

    Time between simulated arrivals or departures, in ms.

    number
  • ticksPerMinute必填

    Ticks that make one simulated minute on the bar chart.

    number
VisitorMap7 个属性
  • cities必填

    Cities with their live visitors and ping counter.

    (RealtimeCity & { pulse: number; })[]
  • color必填

    Marker and ping color. Any CSS color.

    string
  • label必填

    Accessible name for the map.

    string
  • unit必填

    Noun after the visitor count in the tooltip.

    string
  • formatValue必填

    Formats visitor counts.

    (value: number) => string
  • activeId必填

    City id whose marker is lit and shows its tooltip.

    string | null
  • onActiveChange必填

    Called when a marker is hovered, focused or left.

    (id: string | null) => void
类型4 个类型

这些属性使用的对象类型及其字段。

RealtimeCity7 个字段
  • id必填

    Stable id, used as the map marker key.

    string
  • city必填

    City name shown in the tooltip.

    string
  • country必填

    Country name shown under the city.

    string
  • countryCode必填

    ISO 3166 two-letter code, shown as a chip in the Countries list.

    string
  • lat必填

    Latitude in degrees, north positive.

    number
  • lng必填

    Longitude in degrees, east positive.

    number
  • visitors必填

    Visitors on the site from this city right now; 0 hides the marker.

    number
RealtimeRow4 个字段
  • id必填

    Stable id, used as the row key.

    string
  • label必填

    Path, referrer domain or country name.

    string
  • visitors必填

    Visitors on this row right now.

    number
  • code

    Two-letter code chip before the label, used by country rows.

    string
RealtimeEvent7 个字段
  • id必填

    Stable id, used as the row key.

    string
  • cityId必填

    Id of the city the visitor came from, so hovering the row lights its marker.

    string
  • city必填

    City name shown in the row.

    string
  • countryCode必填

    ISO 3166 two-letter code shown as a chip.

    string
  • page必填

    Page the visitor landed on.

    string
  • referrer必填

    Where the visitor came from.

    string
  • at必填

    When it happened, in feed seconds; negative for events before the block mounted.

    number
RealtimeVisitorsLabels19 个字段
  • title必填

    Heading above the live count.

    string
  • live必填

    Text beside the pulsing dot while the feed runs.

    string
  • paused必填

    Text beside the dot while the feed is paused or off.

    string
  • visitors必填

    Noun after the live count.

    string
  • unit必填

    Noun after a city's count in the map tooltip.

    string
  • minutes必填

    Accessible name of the per-minute bars.

    string
  • minutesStart必填

    Caption under the oldest bar.

    string
  • minutesEnd必填

    Caption under the newest bar.

    string
  • delta必填

    Text after the change pill beside the count.

    string
  • activity必填

    Heading above the latest arrivals.

    string
  • now必填

    Age shown for arrivals under five seconds old.

    string
  • from必填

    Joins the page and referrer in an arrival row, as in "/pricing from google.com".

    string
  • map必填

    Accessible name for the map.

    string
  • pages必填

    Pages tab label.

    string
  • referrers必填

    Referrers tab label.

    string
  • countries必填

    Countries tab label.

    string
  • tabs必填

    Accessible name for the list tabs.

    string
  • count必填

    Right column heading in the list.

    string
  • empty必填

    Shown when the selected list has no rows.

    string