better-auth-telegram is a plugin for the Better Auth framework, providing comprehensive Telegram authentication capabilities. It supports various Telegram login methods including the traditional Login Widget, Mini Apps, and the more modern OpenID Connect (OIDC) flow, leveraging OAuth 2.0 Authorization Code flow with PKCE. The library handles HMAC-SHA-256 verification and is built on the Web Crypto API, ensuring compatibility across diverse JavaScript runtimes like Node.js (>=22.0.0), Bun, and Cloudflare Workers, without relying on Node.js-specific `node:crypto` modules. The current stable version is 1.5.0, with an active release cadence addressing features, fixes, and compatibility. It integrates seamlessly with Better Auth's client and server-side components, and offers explicit guidance for database schema updates, making it a robust solution for integrating Telegram login into applications.
npm install better-auth-telegramVerified import paths — ran on the pinned version, not inferred.
Initializes the server-side Telegram authentication plugin for Better Auth using a bot token and username.
Upgrade `better-auth-telegram` to `1.1.0` or higher to ensure compatibility with `better-auth@^1.5.0`. The plugin now uses `defineErrorCodes()` for error code migration.
Ensure you retrieve the correct 'Client Secret' for Web Login from BotFather, not the main bot token. This fix was explicitly addressed in v1.4.0.
Ensure your `createAuthClient` configuration includes `fetchOptions: { credentials: "include" }` to send cookies/credentials with requests.Set `loginWidget: false` in the plugin configuration to disable Login Widget endpoints and omit Telegram-specific schema fields for OIDC-only integrations.
Obtain the correct 'Client Secret' for Web Login from BotFather ('Bot Settings > Web Login') and use it for the `oidc.clientSecret` option.Configure your `createAuthClient` with `fetchOptions: { credentials: 'include' }`.Upgrade `better-auth-telegram` to version `1.1.0` or higher to resolve the type mismatch with `better-auth@^1.5.0`.