7.8.0 • Published 9 months ago
@apiteam/twa-bridge v7.8.0
SDK
npm package for Telegram Web Apps (TWA) SDK.
npm i @apiteam/twa-bridge
Motivation
Telegram distributes SDK via link. It's kinda old fashion way to work with a library:
<html lang="en">
<head>
<title>TWA</title>
<meta charset="UTF-8">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script>
window.Telegram.WebApp.showPopup({ message: 'message' });
</script>
</head>
<body></body>
</html>
This package allows to work with SDK as with a npm package:
import { bridgeOpenPopup } from '@apiteam/twa-bridge/solid'
bridgeOpenPopup({ message: 'message' })
And yes, it supports TS.
Solid
import {
listener,
EventViewportChanged,
bridgeRequestViewport
} from '@apiteam/twa-bridge/solid'
const onRequestViewport = (
eventData: EventsData[typeof EventViewportChanged]
) => {
console.log({eventData})
}
listener.on(EventViewportChanged, onRequestViewport)
bridgeRequestViewport()
Use Context
import {
ProviderTWA,
ContextTwa
} from '@apiteam/twa-bridge/solid'
const Provider = () => {
return (
<ProviderTWA>
<App />
</ProviderTWA>
)
}
const App = () => {
const context = useContext(ContextTwa)
return <div>FisrtName: {context.init?.user?.first_name}</div>
}
Errors
ID | Description |
---|---|
1 | Method not supported |
2 | Ooof! Something is wrong. Init data is missing |
3 | Title too long, maximum length 64 characters |
4 | Your message is too short, at least 1 character |
5 | Your message is too long, maximum 256 characters |
6 | You are passing too few buttons, at least 1 button |
7 | You are passing too many buttons, maximum 3 buttons |
8 | The button text ignores the following values: "ok, close, cancel" |
9 | EDIT_MESSAGE |
7.8.0
9 months ago
7.1.13
10 months ago
7.1.14
10 months ago
7.1.11
10 months ago
7.1.12
10 months ago
7.1.1
10 months ago
7.1.0
10 months ago
7.7.0-beta.1
1 year ago
7.7.0-beta.2
1 year ago
7.0.0-beta.13
1 year ago
7.0.0-beta.11
1 year ago
7.0.0-beta.12
1 year ago
7.0.0-beta.10
1 year ago
7.0.0-beta.8
1 year ago
7.0.0-beta.9
1 year ago
7.0.0-beta.6
1 year ago
7.0.0-beta.7
1 year ago
7.0.0-beta.4
1 year ago
7.0.0-beta.5
1 year ago
7.0.0-beta.2
1 year ago
7.0.0-beta.3
1 year ago
0.0.2-beta.4
1 year ago
7.0.0-beta.1
1 year ago
0.0.2-beta.3
1 year ago
0.0.2-beta.2
1 year ago
0.0.2-beta.1
1 year ago
0.0.1
1 year ago