UNPKG

@telegram-apps/sdk-react

Version:

React bindings for Mini Apps client SDK. Contains hooks, components and other useful tools which allow usage of React along with Mini Apps client SDK.

50 lines (49 loc) 2.16 kB
import { AndroidDeviceData, RetrieveLPResult, RetrieveLPResultCamelCased } from '@telegram-apps/sdk'; /** * Returns the underlying signal value updating it each time the signal value changes. * @param signal - a signal. * @param getServerSnapshot - an optional function returning the signal value snapshot. It is used * only during SSR to provide an initial value of the signal. When not set, defaults to the * signal itself. */ export declare function useSignal<T>(signal: { (): T; sub(fn: VoidFunction): VoidFunction; }, getServerSnapshot?: () => T): T; /** * @returns Launch parameters from any known source. * @param camelCase - should the output be camel-cased. * @throws {LaunchParamsRetrieveError} Unable to retrieve launch parameters. They are probably * invalid. */ export declare function useLaunchParams(camelCase?: false): RetrieveLPResult; /** * @returns Launch parameters from any known source. * @param camelCase - should the output be camel-cased. * @throws {LaunchParamsRetrieveError} Unable to retrieve launch parameters. They are probably * invalid. */ export declare function useLaunchParams(camelCase: true): RetrieveLPResultCamelCased; /** * @returns Launch parameters in a raw format from any known source. * @throws {LaunchParamsRetrieveError} Unable to retrieve launch parameters. They are probably * invalid. * @see retrieveRawLaunchParams */ export declare function useRawLaunchParams(): string; /** * @returns Raw init data from any known source. * @throws {LaunchParamsRetrieveError} Unable to retrieve launch params from any known source. */ export declare function useRawInitData(): string | undefined; /** * Retrieves Android device data from the navigator.userAgent. * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent */ export declare function useAndroidDeviceData(): AndroidDeviceData; /** * Retrieves Android device data from the specified User Agent. * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent * @param userAgent - user agent. */ export declare function useAndroidDeviceDataFrom(userAgent: string): AndroidDeviceData;