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- /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>
);
}
安装
API 参考
除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。
RealtimeVisitors19 个属性
citiesCities with their starting visitors; their sum is the starting live count.
RealtimeCity[]pagesPages with their starting visitors.
RealtimeRow[]referrersReferrers with their starting visitors.
RealtimeRow[]minutesLive count at the end of each of the last minutes, oldest first.
number[]eventsArrivals on screen at mount, newest first.
RealtimeEvent[]maxEventsMost arrivals shown under the list. Set 0 to hide them.
number默认值
3liveSimulate arrivals and departures. Set false to show the data as given.
boolean默认值
trueintervalMsTime between simulated arrivals or departures, in ms.
number默认值
1600ticksPerMinuteTicks that make one simulated minute on the bars.
number默认值
6maxRowsMost rows in the list.
number默认值
5tabControlled list tab.
"pages" | "referrers" | "countries"defaultTabList tab when uncontrolled.
"pages" | "referrers" | "countries"默认值
pagesonTabChangeCalled when a list tab is chosen.
((tab: RealtimeTab) => void)accentColorMap marker and ping color. Any CSS color.
string默认值
#10b981accentClassNameLive dot and newest bar color class.
string默认值
bg-emerald-500barClassNamesList share bar color class for each tab; any tab left out keeps its default.
Partial<Record<RealtimeTab, string>>formatValueFormats visitor counts in the map tooltip.
((value: number) => string)默认值
(value: number) => numberFormat.format(value)labelsCopy overrides; anything left out uses the English defaults.
Partial<RealtimeVisitorsLabels>classNameClasses 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) => voidmaxRows必填Most rows shown at once.
numberreduce必填Skip movement, keep fades.
booleanlabels必填Copy for tabs, headings and the empty state.
RealtimeVisitorsLabelsbarClassNames必填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.
RealtimeRowtab必填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.
numberdelay必填Entrance delay in seconds; 0 for rows that arrive after mount.
numberreduce必填Skip movement, keep fades.
booleanbarClassName必填Share bar color class, such as `bg-emerald-500/15`.
stringrefThe 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.
numbermaxEvents必填Rows kept on screen; the list holds this height so nothing below jumps.
numberactiveCityId必填City id lit on the map, so its rows read as selected.
string | nullonActiveCityChange必填Called with a city id while a row is hovered, and null when it leaves.
(cityId: string | null) => voidreduce必填Skip movement, keep fades.
booleanlabels必填Copy for the heading, ages and the page/referrer joiner.
RealtimeVisitorsLabelsaccentClassName必填Dot color class for the newest arrival, such as `bg-emerald-500`.
stringonPauseChangeCalled 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.
numberto必填Current value.
numbersuffix必填Text after the pill, such as "vs 30 min ago".
stringclassNameClasses merged onto the root element.
string
LiveHeader7 个属性
total必填Visitors online now.
numberminutes必填Per-minute values for the bars, with one off-screen bar on the left.
number[]minuteTick必填Increments on each new minute.
numberrunning必填True while the feed is running; drives the dot's pulse and status text.
booleanreduce必填Skip loops and movement.
booleanlabels必填Copy for the title, status and captions.
RealtimeVisitorsLabelsaccentClassName必填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.
numberreduce必填Skip the slide and growth animations.
booleanbarClassNameClass for the newest bar, such as `bg-emerald-500`.
string默认值
bg-emerald-500restClassNameClass for the older bars.
string默认值
bg-foreground/30label必填Accessible summary of the chart.
stringclassNameClasses 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.
numberactive必填Run the simulation only while true.
booleanintervalMs必填Time between simulated arrivals or departures, in ms.
numberticksPerMinute必填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.
stringlabel必填Accessible name for the map.
stringunit必填Noun after the visitor count in the tooltip.
stringformatValue必填Formats visitor counts.
(value: number) => stringactiveId必填City id whose marker is lit and shows its tooltip.
string | nullonActiveChange必填Called when a marker is hovered, focused or left.
(id: string | null) => void
类型4 个类型
这些属性使用的对象类型及其字段。
RealtimeCity7 个字段
id必填Stable id, used as the map marker key.
stringcity必填City name shown in the tooltip.
stringcountry必填Country name shown under the city.
stringcountryCode必填ISO 3166 two-letter code, shown as a chip in the Countries list.
stringlat必填Latitude in degrees, north positive.
numberlng必填Longitude in degrees, east positive.
numbervisitors必填Visitors on the site from this city right now; 0 hides the marker.
number
RealtimeRow4 个字段
id必填Stable id, used as the row key.
stringlabel必填Path, referrer domain or country name.
stringvisitors必填Visitors on this row right now.
numbercodeTwo-letter code chip before the label, used by country rows.
string
RealtimeEvent7 个字段
id必填Stable id, used as the row key.
stringcityId必填Id of the city the visitor came from, so hovering the row lights its marker.
stringcity必填City name shown in the row.
stringcountryCode必填ISO 3166 two-letter code shown as a chip.
stringpage必填Page the visitor landed on.
stringreferrer必填Where the visitor came from.
stringat必填When it happened, in feed seconds; negative for events before the block mounted.
number
RealtimeVisitorsLabels19 个字段
title必填Heading above the live count.
stringlive必填Text beside the pulsing dot while the feed runs.
stringpaused必填Text beside the dot while the feed is paused or off.
stringvisitors必填Noun after the live count.
stringunit必填Noun after a city's count in the map tooltip.
stringminutes必填Accessible name of the per-minute bars.
stringminutesStart必填Caption under the oldest bar.
stringminutesEnd必填Caption under the newest bar.
stringdelta必填Text after the change pill beside the count.
stringactivity必填Heading above the latest arrivals.
stringnow必填Age shown for arrivals under five seconds old.
stringfrom必填Joins the page and referrer in an arrival row, as in "/pricing from google.com".
stringmap必填Accessible name for the map.
stringpages必填Pages tab label.
stringreferrers必填Referrers tab label.
stringcountries必填Countries tab label.
stringtabs必填Accessible name for the list tabs.
stringcount必填Right column heading in the list.
stringempty必填Shown when the selected list has no rows.
string