VK Bridge React
React hooks for VK Bridge.
In addition, the library provides other helper functions.
Usage
npm install @vkontakte/vk-bridge @vkontakte/vk-bridge-react
import { useInsets, runTapticImpactOccurred } from '@vkontakte/vk-bridge-react';
// Sends event to client
const App = () => {
const insets = useInsets();
const handleClick = () => {
runTapticImpactOccurred();
};
return (
<div style={{ paddingTop: insets?.top }}>
<button onClick={handleClick}>Touch me and feel</button>
</div>
);
};
Hooks
Name | Return type | Description |
useAppearance() |
type UseAppearance = AppearanceType | null; |
Hook listens to update the
|
useAdaptivity() |
interface UseAdaptivity {
type: null | AdaptivityType;
viewportWidth: number;
viewportHeight: number;
} |
Hook listens to update the adaptivity property of the VKWebAppUpdateConfig event. |
useInsets() |
type UseInsets = {
top: number;
right: number;
bottom: number;
left: number;
} | null; |
Hook listens to update the
|
Helpers
Name | Return type | Description |
runTapticImpactOccurred |
boolean |
Function dispatches VKWebAppTapticImpactOccurred event if it is support (will return true ). |