Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tips & Gotchas

Topic
Guidance

Register callbacks before initial reads

Live updates can arrive before or after your first getValue / getValues. Register setCallbacks first, key rendering on index, and make it safe to repeat.

getValues() can be empty for two reasons

No datastreams assigned — or, on web, nothing delivered yet. Render a neutral state and let onValueUpdated fill it in.

Value objects always carry the full field set

Missing fields default to null, '' or []. Check type, never field presence.

value is a string, or null

Even for INT and DOUBLE. Parse it, and handle null before the first push.

ENUM value is an index string

Resolve with v.mappings[idx] ?? v.enumFallbackValue ?? v.value.

Compare type case-insensitively

v.type.toUpperCase() === 'ENUM' works on every host.

sendValue gives no confirmation

Synchronous and fire-and-forget. Index errors arrive via onError; selector errors are also thrown — wrap them in try/catch.

Selectors match the name, not the alias

{ name } matches the datastream name; { pin } matches virtual pins only. On web, resolve selectors after the first value update.

getHistoricalData always needs dataStreams

Including RANGE_PICKER. 1 to 10 entries, each with an index and a sourceType.

CUSTOM needs from < to

Equal timestamps are rejected, and history spans are capped at 365 days.

Out-of-range history indexes are silent

Invalid entries are dropped; only an all-invalid request rejects.

offset is for RAW_DATA pagination

Keep period, from and to identical and grow offset by the points received.

RANGE_PICKER subscription order

Register onHistoricalDataUpdated / onMapDataUpdated before subscribing.

Guard on info.id

getDeviceInfo() resolves an object even with no bound device; id is null then.

Always give the device image a fallback

image can be null or fail to load — show the name's initial, never a broken-image icon.

status is a flat string

'ONLINE', 'OFFLINE', a custom value or ''. Compare with .toUpperCase().

Feature-detect newer families

Tags, files, assets and native screens can be missing on an older host. Leave that part out when the method is missing.

Check files yourself before uploading

.png / .jpg / .jpeg / .ico, 1 B to 10 MiB, one upload at a time. Revoke object URLs you create for blobs.

Native screens need a user gesture

Call openDeviceInfo() and friends directly in a click or tap handler, never after an await.

Dashboard pages are mobile-only and index-based

getPages()[i] ↔ showPage(i). Never pass a page id. Guard with isPageActionsSupported() and typeof bridge.showPage === 'function'.

Theme colors are already mode-resolved

Don't re-derive them from prefers-color-scheme; keep CSS fallbacks for the editor only. Derive tints with color-mix().

Check permissions, but tolerate rejection

Names a host doesn't accept reject with invalid_request — fall back instead of hard-blocking.

logEventId is a string

64-bit IDs lose precision as numbers; a number rejects.

Event text limits

300 for comments and note titles, 2000 for note descriptions; keep resolveComment within 300 for portable widgets.

Storage is per user, per browser or phone

Never shared between users, never synced across devices. Plain JSON only; 16 KB per value, 512 KB and 1024 items per account.

Data Engine queries are org-scoped

The bound device doesn't limit the rows. limit: 0 (the default) means the server's row cap.

Errors come twice

Requests report through sendError before rejecting — in .catch() only update state.

Branch on error.code, not on text

Messages are for humans and change; code and details are the contract.

isExternalRequestsAllowed() is false on web

Check before fetch(), and handle rejections — CORS can still block a request on mobile.

No external scripts in production

CDN fonts and icon libraries add latency; inline assets or use system fonts.

No innerHTML with bridge data

Values, event text, tag and page names, file names and metadata are untrusted. Use textContent / setAttribute.

Don't touch the host globals

The app calls the window.blynk* functions directly; destroy() is how you detach.

overscroll-behavior: none

Set it on html, body so the widget doesn't hijack dashboard scrolling.

touch-action: manipulation

Removes the 300 ms tap delay without disabling pinch-zoom.

-webkit-user-select: none

Prevents accidental text selection while the user scrolls the dashboard.

Preview and editor mode

When isBridgeAvailable() is false, render placeholder content so the widget looks meaningful in the editor.

Was this helpful?