Telegram Web K is configured through a combination of environment variables loaded by Vite at build time and a small set of URL query parameters parsed at runtime. Environment variables live inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/TelegramOrg/Telegram-web-k/llms.txt
Use this file to discover all available pages before exploring further.
.env and .env.local files at the project root. The .env file ships with the repository and contains sensible defaults for local development; .env.local is your personal override file and is never committed to version control.
Getting Telegram API credentials
Every Telegram client — official or third-party — must register an application to receive an API ID and hash. These values identify your client to Telegram’s servers and are required before the app will connect.Open the Telegram API portal
Go to my.telegram.org and log in with the phone number linked to your Telegram account. Telegram will send a confirmation code to your Telegram app.
Create a new application
Navigate to API development tools and fill in the form:
- App title: any name (e.g.,
My Web K Dev) - Short name: a short identifier (e.g.,
mywebk) - Platform:
Web - Description: optional
Environment variables
Vite reads.env and .env.local files at startup. Variables prefixed with VITE_ are exposed to client-side code via import.meta.env. Variables without that prefix are only available during the Vite build process itself.
On first run in development mode, Vite automatically copies .env.local.example to .env.local if the file does not exist. You can also copy it manually:
.env.local and override the variables you need. Values in .env.local take precedence over .env.
Core variables
Your Telegram application’s API ID, obtained from my.telegram.org. The
.env file ships with a development credential (1025907) that works for local testing, but you should replace it with your own.Your Telegram application’s API hash, obtained from my.telegram.org. Paired with
VITE_API_ID to authenticate your client.The VAPID public key for Web Push notifications. Required to receive push notifications when the app is in the background. Leave empty to disable push notifications.
The public version string shown in the app’s about screen (e.g.,
2.2).The full version string including build number (e.g.,
2.2 (649)).The numeric build identifier. Used internally for change detection and cache busting.
MTProto transport variables
These variables control how the MTProto layer establishes connections to Telegram’s servers. The defaults in.env enable both WebSocket and HTTPS transports with automatic selection.
Run MTProto networking in a dedicated Web Worker. Recommended — keeps network I/O off the main thread.
Run MTProto inside the Service Worker instead of a Web Worker. Leave empty for the default Worker-based setup.
Enable automatic transport selection. When set alongside
VITE_MTPROTO_HAS_HTTP and VITE_MTPROTO_HAS_WS, the client starts with HTTP and upgrades to WebSocket when available.Allow the HTTPS transport for MTProto connections.
Allow the WebSocket transport for MTProto connections.
Example .env.local
A minimal override file for development with your own credentials:
App config object
src/config/app.ts defines the App object that the rest of the codebase imports for runtime constants. Most fields are populated from import.meta.env (the Vite environment), but some are computed at startup.
Main domain override
When the app detects it is running on an official Telegram domain (web.telegram.org or webk.telegram.org), it replaces the API credentials with Telegram’s own production keys:
Thread counts
threads, lottieWorkers, and cryptoWorkers are all set to Math.min(4, navigator.hardwareConcurrency ?? 4). On a machine with 8+ logical cores this is 4; on a dual-core machine it is 2. You cannot override these at runtime — they are computed once at module load.
Runtime query parameters
These parameters are parsed bysrc/config/modes.ts on every page load. Append them to any URL where the app is running.
| Parameter | Type | Default | Description |
|---|---|---|---|
test=1 | flag | off | Connect to Telegram’s test data centers. Messages and accounts on test DCs are separate from production. |
debug=1 | flag | off | Enable verbose logging. In development (IS_BETA), debug logging is always on regardless of this flag. |
noSharedWorker=1 | flag | off | Disable the Shared Worker. Each tab opens its own network connection — useful for isolating network traffic in DevTools. |
noServiceWorker=1 | flag | off | Disable the Service Worker. Push notifications and file streaming fall back to the main thread. |
http=1 | flag | off | Force the HTTPS transport for MTProto connections (requires VITE_MTPROTO_HAS_HTTP=1). |
noMultipleTransports=1 | flag | off | Disable automatic transport switching even when VITE_MTPROTO_AUTO is enabled. |
Debug mode behavior
src/config/debug.ts exports a DEBUG constant and a MOUNT_CLASS_TO object:
DEBUG is true, internal service classes are attached to window (or self in workers) via MOUNT_CLASS_TO. This lets you inspect live state in the browser console without a debugger breakpoint. For example, after the app loads you can type the class name directly in DevTools to inspect its current state.
Source maps are included in production builds, so you can set breakpoints in the original TypeScript source even on a deployed build.
SSL configuration
By default the dev server runs over plain HTTP onlocalhost:8080. To run over HTTPS — for example to test Service Worker behavior or push notifications that require a secure context — edit vite.config.ts:
web.telegram.org, add 127.0.0.1 web.telegram.org to /etc/hosts, and place the cert files in ./certs/. The server will start at https://web.telegram.org/.
The
@vitejs/plugin-basic-ssl plugin is available in vite.config.ts for generating self-signed certificates when USE_SELF_SIGNED_CERTS is set to true. Self-signed certificates work for local testing but will show a browser security warning.