vkui-bridge
@vkma.dev/vkui-bridge is React glue between @vkma.dev/bridge and @vkontakte/vkui. The provider streams the host’s theme, safe-area insets and adaptivity from bridge events into a ready ConfigProvider shell. Semantics copy @vkontakte/vk-bridge-react.
npm install @vkma.dev/vkui-bridge# peers: @vkma.dev/bridge ^0.2.0, @vkontakte/vkui ^8.0.0, react ^18 | ^19main.tsx of a VK Mini App:
import bridge from "@vkma.dev/bridge";import { VKBridgeConfigProvider } from "@vkma.dev/vkui-bridge";import { StrictMode } from "react";import { createRoot } from "react-dom/client";import { App } from "./App";import "@vkontakte/vkui/dist/vkui.css";
// Tell the host the app is ready: folds the host preloader, enables history.void bridge.send("VKWebAppInit");
createRoot(document.getElementById("root")!).render( <StrictMode> <VKBridgeConfigProvider> <App /> </VKBridgeConfigProvider> </StrictMode>,);VKBridgeConfigProvider composes ConfigProvider → AdaptivityProvider → AppRoot(mode="full") with bridge-computed defaults:
| ConfigProvider prop | Source |
|---|---|
colorScheme |
VKWebAppUpdateConfig plus a VKWebAppGetConfig bootstrap (useBridgeAppearance) |
platform |
"vkcom" when vk_platform === "desktop_web" in the launch params |
isWebView |
bridge.isWebView() |
hasCustomPanelHeaderAfter |
always true, reserving the PanelHeader corner for the host controls |
AdaptivityProvider props |
host adaptivity via transformVKBridgeAdaptivity(useBridgeAdaptivity()) |
AppRoot.safeAreaInsets |
VKWebAppUpdateInsets and config insets via useBridgeInsets |
Any prop the app passes explicitly wins over the computed value. The provider accepts the whole ConfigProvider prop surface and spreads it last.
Every hook reads the default bridge instance.
useBridgeAppearance()returnsColorSchemeType | undefined. StreamsVKWebAppUpdateConfigand bootstraps withVKWebAppGetConfig. Outside a mini app it returnsundefined— VKUI resolves the theme itself.useBridgeInsets()returnsSafeAreaInsets | undefined. ReadsVKWebAppUpdateInsetsand the insets field of the config. Abottombeyond 150 becomes0— the virtual-keyboard clamp.useBridgeAdaptivity()returns{ type, viewportWidth, viewportHeight }.typeis the host verdict (adaptive,force_mobile,force_mobile_compact, ornull) plus the viewport at the last change.