Overview
grammY is available for multiple JavaScript runtimes and can be installed using your preferred package manager. Choose the installation method that matches your environment.grammY requires Node.js 12.20.0 or higher, or the latest version of Deno.
Node.js Installation
grammY is available on npm as thegrammy package. You can install it using any Node.js package manager.
- npm
- yarn
- pnpm
Usage in Node.js
After installation, import grammY in your project:Version Requirements
grammY supports the following Node.js versions:- Node.js 12.20.0 or higher
- Node.js 14.13.1 or higher (recommended)
- All current LTS versions
Deno Installation
grammY runs natively on Deno without any transpilation. All grammY packages are published to deno.land/x.Usage in Deno
Import grammY directly from the Deno module registry:Running with Deno
When running your bot, you need to grant network permissions:Why Deno Support?
grammY is developed primarily for Deno and then compiled to Node.js. This approach provides:- Native Deno support with no transpilation needed
- Modern JavaScript features out of the box
- Type safety with built-in TypeScript support
- Secure by default with explicit permissions
While grammY is Deno-first, the documentation is written Node.js-first since most bot developers still use Node.js. All examples work on both platforms.
Browser & Edge Installation
grammY can run in browsers and on edge platforms like Cloudflare Workers, Deno Deploy, and more.Using Web Bundle (Node.js)
For Node.js projects that need browser compatibility:The web bundle is included in the npm package and doesn’t require separate installation.
Using Deno Bundle
For browsers or edge runtimes, grammY is available as a JavaScript bundle via bundle.deno.dev:Cloudflare Workers Example
Package Exports
The grammY package provides multiple entry points for different use cases:Main Export
Bot- Main bot classContext- Context object for handling updatesComposer- Middleware compositionApi- Telegram Bot API wrapper- All convenience utilities (keyboard, inline query, etc.)
Web Export
- Cloudflare Workers
- Deno Deploy
- Service Workers
- Browser applications
Types Export
- All Telegram Bot API types
- Update types
- Message types
- And more
The
grammy/types export provides access to the underlying @grammyjs/types package, which contains TypeScript definitions for the entire Telegram Bot API.TypeScript Support
grammY has first-class TypeScript support with complete type definitions.Installation for TypeScript
TypeScript Configuration
Add atsconfig.json file to your project:
Type Inference
grammY provides excellent type inference. Your editor will automatically suggest available methods and properties:Dependencies
grammY has minimal dependencies to keep your bundle size small:Node.js Dependencies
@grammyjs/types- TypeScript definitions for Telegram Bot APInode-fetch- HTTP client for making API callsabort-controller- For cancelling requestsdebug- Debugging utility
Deno Dependencies
Deno version has zero dependencies - everything is built using Deno’s standard library.Verifying Installation
After installation, verify that grammY is working correctly:/start to your bot. If you get a response, everything is working!
Updating grammY
Node.js
- npm
- yarn
- pnpm
Deno
Update the version number in your import URL:Troubleshooting
”Cannot find module ‘grammy’”
Make sure you’ve installed grammY:“Error: Empty token!”
You need to provide a valid bot token from @BotFather:Permission Errors (Deno)
Make sure to grant network permissions:Node.js Version Too Old
Upgrade to Node.js 14.13.1 or higher:Next Steps
Now that you have grammY installed, you’re ready to build your bot!- Follow the Quickstart guide to create your first bot
- Explore the API Reference to learn about available methods
- Check out Examples for inspiration
Getting Help
If you run into issues during installation:- Check the FAQ for common questions
- Ask in the Telegram Chat
- Open an issue on GitHub