JSPM

@grammyjs/web-app

1.3.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 141
    • Score
      100M100P100Q78636F
    • License MIT

    Building blocks for Telegram Web Apps

    Package Exports

    • @grammyjs/web-app
    • @grammyjs/web-app/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@grammyjs/web-app) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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.