@seatschart/react-native
v0.17.0
Published
React Native component for SeatsChart seat maps (WebView + native bridge) for ticketing buyer apps
Maintainers
Readme
@seatschart/react-native
The SeatsChart buyer seat map for React Native and Expo apps: the WebGL viewer runs in a
react-native-webview and talks to your app through
a native bridge, with typed callbacks in and promise commands out. Same config, events and commands as the web
loader (@seatschart/embed) and the React wrapper (@seatschart/react).
Install
# Expo
npx expo install react-native-webview
npm install @seatschart/react-native
# Bare React Native
npm install @seatschart/react-native react-native-webview
cd ios && pod installRequirements: React Native 0.74+ (Hermes with TextEncoder and btoa), react-native-webview 13+. The package
builds viewer URLs with URL / URLSearchParams: Expo SDK 52+ ships standard implementations; on bare React Native
older than that, add react-native-url-polyfill and import "react-native-url-polyfill/auto" in your entry file.
Buyer token (never ship a secret in an app)
The chart needs a short-lived buyer token. Your backend mints it with its API key and your app fetches it from
your backend. Never put an API key (sk_…) or any other secret in a mobile app: apps can be unpacked.
# On your server, with your partner API key
curl -X POST https://api.seats.example.com/api/viewer-tokens \
-H "x-api-key: $SEATSCHART_API_KEY" -H "Content-Type: application/json" \
-d '{"ttlSeconds":900}'
# → { "token": "eyJ…", "expiresAt": "…" }workspaceKey (pub_…) is public and can live in the app.
Seat chart
import { useRef } from "react";
import { Button, View } from "react-native";
import { SeatsChartView, type SeatsChartHandle } from "@seatschart/react-native";
export function PickSeats({ token, onCheckout }: { token: string; onCheckout: (holdToken: string) => void }) {
const chart = useRef<SeatsChartHandle>(null);
return (
<View style={{ flex: 1 }}>
<SeatsChartView
ref={chart}
webBase="https://seats.example.com"
event="00000000-0000-4000-8000-000000000000"
token={token}
workspaceKey="pub_0123456789abcdef0123456789abcdef"
language="pt"
session="continue"
maxSelectedObjects={6}
pricing={{ prices: [{ category: "VIP", price: 250 }, { category: "Floor", price: 120 }] }}
legend={{ hidePricing: false }}
onChartRendered={(event, chartHandle) => console.log("ready", event.objectCount, chartHandle.holdToken)}
onObjectSelected={(event) => console.log("selected", event.label)}
onHoldSucceeded={(event) => console.log("held", event.objectIds)}
onHoldFailed={(event) => console.warn(event.message)}
onHoldTokenExpired={() => console.log("hold expired")}
onSelectionInvalid={(event) => console.warn(event.reason)}
/>
<Button
title="Checkout"
onPress={async () => {
const session = await chart.current?.getHoldToken();
if (session) onCheckout(session.holdToken);
}}
/>
</View>
);
}Your server then confirms the hold (POST /api/seats/confirm with the hold token) after payment, exactly as for
the web embed.
Expo Router screen
import { useLocalSearchParams } from "expo-router";
import { SeatsChartView } from "@seatschart/react-native";
import { useBuyerToken } from "../lib/use-buyer-token"; // fetches the token from your backend
export default function EventSeats() {
const { eventId } = useLocalSearchParams<{ eventId: string }>();
const token = useBuyerToken(eventId);
if (!token) return null;
return <SeatsChartView webBase="https://seats.example.com" event={eventId} token={token} colorScheme="auto" />;
}Props
Every key of the buyer host config: event / events, token, workspaceKey / publicKey, channel,
channelKey(s), session / sessionMode, holdToken, season, language, maxSelectedObjects,
selectedObjects, availableCategories / unavailableCategories, currency, pricing, priceFormatter,
partySize, style (renderer font, corner radius, button shape), objectPopover, legend, filterControls,
showLegend, showMinimap, activeFloor, lockActiveFloor, showFloorElevator, holdOnSelectForGAs, objectColor, objectLabel,
tooltip, prompts, mode, fitTo, messages…
| Native prop | Meaning |
| --- | --- |
| webBase | SeatsChart viewer URL (required). |
| colorScheme (alias theme) | light, dark or auto. Default: the app's colour scheme when the chart mounts. |
| parentOrigin | Origin sent as parent_origin. Default: the viewer origin. Set one of your workspace's allowed embed origins when your deployment does not allow its own origin. |
| containerStyle | Style of the view that holds the WebView (style is the renderer style). |
| loadingIndicator | Shown while the page loads; null for none. |
| webViewProps | Extra react-native-webview props (bridge and navigation props are managed). |
Callbacks (seats.io names included): onChartRendered(event, chart), onChartRenderingFailed, onObjectClicked,
onObjectSelected, onObjectDeselected, onObjectMouseOver / onObjectHovered, onSessionInitialized,
onHoldSucceeded, onHoldFailed, onHoldCallsInProgress, onHoldCallsComplete, onReleaseHoldSucceeded,
onReleaseHoldFailed, onHoldTokenExpired, onSelectionValid, onSelectionInvalid, onSelectedObjectUnavailable,
onSelectedObjectBooked, onBestAvailableSelected, onBestAvailableSelectionFailed, onFilteredCategoriesChanged,
onFiltersChanged, onFloorChanged, onFullScreenRequest, onHoldCreated… Host-drawn prompts:
onPlacesPrompt, onTicketTypePrompt and onPlacesWithTicketTypesPrompt receive confirm / cancel.
Host objects (seats.io object model)
onObjectSelected / onObjectDeselected props receive the whole object: onObjectSelected(object, selectedTicketType) / onObjectDeselected(object), and
findObject(idOrLabel) and listSelectedObjects({ detailed: true }) return the same shape. Besides the historical
objectId, label, category (name), status, price (cents), forSale, rowLabel, sectionId,
displayedLabel, accessibility and entrance, it carries objectType (seat, generalAdmission, table,
section), labels { own, parent, section, displayedLabel }, sectionLabel, categoryInfo { key, label, color },
pricing { price, formattedPrice, ticketTypes[] } (ticket types with formattedPrice), selectedTicketType,
selected, selectable, isOrphan, floor, zone, center and resaleListingId; general admission areas and
GA tables add capacity, numFree, numBooked, numHeld, numSelected, selectionPerTicketType,
bookAsAWhole, areaType; tables tableType and seats; sections numberOfSelectableObjects,
numberOfSelectedObjects, selectableCategories, isInteractive, sectionCategory. Every object has
displayObjectType; seats add parent (row or table) and viewFromSeatUrl; on season and multi-event charts
dataPerEvent and seasonStatusOverriddenQuantity. The viewer builds it from what it already shows (no extra
request, at most 2 KB per object). Objects have the seats.io methods select(ticketType?), deselect(ticketType?),
pulse(), unpulse() and isInChannel(channelKey). deselectObjects takes ids, labels, { label, ticketType }
and { label, amount, ticketType? } (general admission places); unpulse(ids) and unhighlightObjects(ids) act on
those objects only; a host selectObjects refuses categories outside availableCategories / in
unavailableCategories. Types: ChartObject, ChartObjectInfo, ChartObjectDetails (exported by
@seatschart/embed and this package).
Best available that holds, 3D camera, fullscreen. holdBestAvailable({ number | ticketTypes, categories, zone,
sections, accessibleSeats }) holds the best seats atomically on the chart's hold session (booking limits and the category
lists apply), fires onHoldSucceeded / onHoldFailed and resolves { objects, nextToEachOther }; selectBestAvailable
takes the same options. With the 3D view open, zoomToObjects, zoomToSection, zoomToZone, zoomToSelectedObjects and
zoomToFilteredCategories frame the 3D camera and resetView returns it; set3DCameraPreset("isometric" | "stage"),
get3DCameraState() and set3DCameraState(state) drive it; in 3D isometricView() / stageView() are those presets,
while in 2D they switch the multi-floor all-floors perspective (seats.io; multiFloor.view). Also openFullScreen() / closeFullScreen(),
setFilteredSection(section) / clearFilteredSection(), clickConfirmationButton() and previewObjectChanges(changes) /
resetObjectChanges() (temporary colour, label or visibility of objects; nothing is saved). Types: BestAvailableParams,
HoldBestAvailableResult, Chart3DCameraState.
Guided selection, seat search, colours, connection callbacks. stepThrough: { enabled: true } replaces the
best-available panel with a guide (where → how many → review the seats found: keep or change; keyboard and screen
reader ready, closable at any step) and, under 650 px, a List places carousel (floors → sections → rows →
seats, the place shown highlighted on the map); showSearchButton adds a seat search to the map controls; colors (selected,
accent, tooltipBackground, title, error; seats.io names accepted) restyles seats and chrome in light and dark;
inputDevice (auto | cursor | touch), showActiveSectionTooltipOnMobile, multiFloor.alwaysColorizeBezels / multiFloor.view ("stage" | "isometric"), the selection menu's
"Select whole rows" (off when maxSelectedObjects is set),
selectableObjects { label, amount } (general admission places), objectWithoutChannelSelectable: false (only the
objects of the channelKeys channels; seats.io channels without NO_CHANNEL) and maxSelectedObjects up to 1000
(the channel's order limit and the booking rules still apply). Callbacks onOrphanSeatsChanged
({ objectIds, added, removed }), onHoldTokenCreationFailed ({ message, status }), onRealtimeConnectionLost /
onRealtimeConnectionRestored (seats.io onWebsocketConnectionClosed). Types: ChartColorsConfig, InputDevice,
StepThroughConfig, ChartOrphanSeatsChanged, ChartHoldTokenCreationFailed.
Ref methods
All return promises that wait for the chart to render: selectObjects, deselectObjects, trySelectObjects,
doSelectObjects, clearSelection, listSelectedObjects, selectBestAvailable, selectCategories,
deselectCategories, findObject, listCategories, listZones, setFilteredCategories, setFilters,
clearFilters, goToFloor, listFloors, goToAllFloorsView, zoomToObjects, zoomToSelected, zoomToSection, resetView, highlightObjects, setSpotlight, pulse, getHoldToken,
startNewSession, releaseHoldToken, isObjectInChannel, showViewFromSeat (the 3D view from a seat; "photo"
on devices without 3D), getReportBySelectability, changeConfig,
setPricing, exportImage (always a data URL), resolvePrompt. Synchronous: holdToken, session,
selectedObjects. Also whenReady(), rerender() (reload, keeping the hold session) and setFullScreen(active).
Fullscreen: a WebView already fills the area you give it, so the viewer's fullscreen button is hidden unless you
pass onFullScreenRequest (expand your screen, then call setFullScreen(true)).
Migrating from @seatsio/seatsio-react-native
| seats.io | SeatsChart |
| --- | --- |
| <SeatsioSeatingChart> | <SeatsChartView> (alias SeatingChart) |
| region="eu" | webBase="https://seats.example.com" |
| workspaceKey, event, session, holdToken, pricing, language | same names |
| onChartRendered={(chart) => …} | onChartRendered={(event, chart) => …} or a ref |
| chart.getHoldToken() | ref.current.getHoldToken() (or the synchronous holdToken) |
| JavaScript function strings (objectColor="(object) => …") | declarative objectColor / objectLabel / tooltip objects (no code runs from the app) |
Other seats.io renderer names work unchanged in <SeatsChartView> too: channels, defaultRenderingEngine, showSectionContents: "onlyAfterZoom", maxSelectedObjects limiter arrays, objectTooltip, categoryFilter, filteredCategories, filters, listings, legacy selectedSeats / onSeatSelected names and seats.io messages keys (one development warning per mapped key). chart.changeConfig takes availableCategories, unavailableCategories, filters and filteredCategories; setAvailableCategories / setUnavailableCategories grey categories out live.
How the bridge works
The viewer loads with ?bridge=react-native. When it runs top-level in a WebView that exposes
window.ReactNativeWebView, it sends its events and command results there (after the same parent_origin
allowlist as an iframe) and accepts commands through window.SeatsChartBridge.receive, which this component calls
with injectJavaScript. Without the parameter, or in a normal browser, nothing changes. Navigation is limited to the
viewer origin; other links open in the system browser.
License
MIT
