@telegram-apps/sdk-solid
Solid.js package providing utilities that developers may find useful when developing a mini application.
Installation
Before proceeding, it is assumed that you have already installed the solid-js
package, as it is a peer dependency of this package.
bash
pnpm i @telegram-apps/sdk-solid
bash
npm i @telegram-apps/sdk-solid
bash
yarn add @telegram-apps/sdk-solid
INFO
This package fully re-exports the @telegram-apps/sdk package, so you don't need to install it separately.
Hooks
useSignal
A helper that allows you to use our signals in the application. It returns a Solid signal which updates every time, our signal changes.
ts
import { createEffect, onCleanup, onMount } from 'solid-js';
import { backButton, useSignal } from '@telegram-apps/sdk-solid';
function Component() {
const isVisible = useSignal(backButton.isVisible);
createEffect(() => {
console.log('The button is', isVisible() ? 'visible' : 'invisible');
});
onMount(() => {
backButton.show();
onCleanup(() => {
backButton.hide();
});
});
return null;
}
useLaunchParams
A function that returns the mini application's launch parameters.
tsx
import { useLaunchParams } from '@telegram-apps/sdk-solid';
function Component() {
const lp = useLaunchParams();
return <div>Start param: {lp.startParam}</div>;
}