@grammyjs/web-app
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

grammY Web App Utils


Building Blocks for Telegram Web Apps

This repo provides an npm package for building Web App for your Telegram bot. It simply re-exports the API provided by Telegram's JS module which you must still script-tag include.

The advantage of this package is that is bundles up TypeScript types, which may make it easier to set up the project. In addition, it will allow you to properly scope access to window.Telegram, rather than relying on the global scope.

Installation

You need to include the CDN script from Telegram. Add this to your main HTML file in the <head> tag:

<script src="https://telegram.org/js/telegram-web-app.js"></script>

You can then use this package in your application by running

npm install @grammyjs/web-app

In turn, you can import from it:

import { WebApp } from "@grammyjs/web-app";

console.log(WebApp.initData);
// same as
console.log(window.Telegram.WebApp.initData);

Once your application is ready to be displayed, you should call ready().

WebApp.ready();

Consult the offical Telegram docs for Web Apps to see what else is available through WebApp.

Package Sidebar

Install

npm i @grammyjs/web-app

Weekly Downloads

47

Version

1.3.0

License

MIT

Unpacked Size

3.5 kB

Total Files

5

Last publish

Collaborators

  • knorpelsenf