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 リファレンス
必須と記された props 以外はすべて省略できます。データ、文言、色はサンプルの内容が既定値です。
RealtimeVisitors19 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の props
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 個の型
これらの props が受け取るオブジェクト型とそのフィールド。
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