Reference
sprintelex.js bridge reference
Inside a mini app, the client injects window.SprinTelex before your page loads. This is the complete v1 surface: every member below, nothing more. The bridge version is 1.0.
Identity
version: string
The bridge version, "1.0" in v1.
initData: string
The raw signed launch payload: LF-joined key=value lines (app_id, auth_date, user) plus a trailing hash line. POST this to your server and validate it there; never make trust decisions from anything else.
initDataUnsafe: object
The same fields parsed into an object (user is JSON-parsed). Convenient for rendering the user's name. The name says it all: this is client data, validate initData server side before you trust it.
isVersionAtLeast(v: string): boolean
Feature check. In v1 this is a strict equality check against "1.0", so isVersionAtLeast("1.0") is true and anything else is false. Gate newer members behind it as the bridge grows.
Theme
colorScheme: "light" | "dark"
The user's current SprinTelex appearance. Read it at startup to pick your stylesheet.
themeParams: object
The client palette as CSS-ready hex colors:
{
bg_color: "#ffffff",
text_color: "#111111",
hint_color: "#8a8a8a",
button_color: "#1a9e4b",
button_text_color: "#ffffff"
}Lifecycle
ready(): void
Tell the client your UI has rendered. The viewer shows a loading indicator until you call this, so call it as soon as your first paint is done.
close(): void
Close the app and return the user to the chat.
expand(): void
Request maximum height. The v1 viewer is already full height, so this is acknowledged and is a no-op; call it anyway for forward compatibility.
Native UI
showAlert(message: string, callback?: () => void): void
Show a native alert titled with your app's name. The callback fires when the user taps OK.
showConfirm(message: string, callback?: (ok: boolean) => void): void
Show a native confirm dialog (Cancel / OK). The callback receives true when the user taps OK and false on Cancel.
hapticFeedback(kind?: string): void
Trigger haptics. "success" plays the success pattern, "error" the error pattern, and anything else (including the default "impact") a light tap.
BackButton
A back chevron in the viewer's client chrome:
SprinTelex.BackButton.show(); // reveal the chevron
SprinTelex.BackButton.hide(); // hide it again
SprinTelex.BackButton.onClick(() => {
// user tapped the chevron: go back one step in your app
});MainButton
A full-width action bar pinned to the bottom of the viewer (default label "Continue"):
SprinTelex.MainButton.setText("Pay GH₵ 12.00");
SprinTelex.MainButton.show();
SprinTelex.MainButton.onClick(() => {
SprinTelex.sendData({ confirmed: true });
});
SprinTelex.MainButton.hide();Outbound
openLink(url: string): void
Open an HTTPS URL in the system browser, outside the viewer. Only https: URLs are honored; anything else is ignored.
sendData(data: unknown): void
Post a payload back to the bot and close the app. Strings are sent as-is; objects are JSON-encoded. The payload must be at most 4KB (larger payloads are refused with a "Too much data" alert). Your bot receives an app_data update with the payload as a string.
Events
onEvent(name: string, callback: (params?: unknown) => void): void
offEvent(name: string, callback: Function): void
Subscribe and unsubscribe from client events. No named events are emitted by the client in v1 (button clicks arrive through BackButton.onClick and MainButton.onClick); the subscription API is stable for future events.
Not in v1
These are explicitly out of scope for the v1 bridge: sharing to chats, geolocation, device sensors (motion, orientation), biometrics, clipboard read, contact access, QR/camera capture, cloud or secure storage, write-access prompts, and home-screen install. If your app needs one of these, do it on your own site outside the viewer.
invoke(method, args) gateway by design. Every callable is listed on this page, and each one is validated as attacker input on the client.