react-native-tdlib
v2.2.1
Published
React Native wrapper for TDLib
Maintainers
Readme
Why
Building a Telegram client should not start with an hour-long TDLib compile. This library ships prebuilt TDLib binaries for iOS (xcframework, device + simulator) and Android (arm64-v8a, armeabi-v7a, x86_64), wraps the whole API in a single RN module, and streams every update to JS through NativeEventEmitter.
- 🚀 51 first-class methods — auth, chats, messages, reactions, files, options, users.
- 🔄 Real-time updates — new messages, typing, read receipts, download progress, reactions.
- 🧩 Cross-platform parity — iOS and Android emit the same TDLib JSON shape. Write once.
- 🟦 Fully typed —
.d.tscovers every method, event and result. - 📦 Zero native setup — no
cmake, nobrew install.pod installand go. - 🎬 Ships with a Telegram-like example app — auth wizard, chat list, message view, reactions, reply, typing.
Install
npm install react-native-tdlib
cd ios && pod installRequires React Native ≥ 0.60 (autolinking), iOS ≥ 11, Android minSdk ≥ 21.
Hello, Telegram
import TdLib from 'react-native-tdlib';
import {NativeEventEmitter, NativeModules} from 'react-native';
const emitter = new NativeEventEmitter(NativeModules.TdLibModule);
// 1) Start TDLib
await TdLib.startTdLib({api_id: 12345, api_hash: 'your_hash'});
// 2) Listen for everything
emitter.addListener('tdlib-update', e => {
if (e.type === 'updateNewMessage') {
console.log('📨', JSON.parse(e.raw).message);
}
});
// 3) Log in (drive via updateAuthorizationState — see docs)
await TdLib.login({countrycode: '+1', phoneNumber: '5551234567'});
await TdLib.verifyPhoneNumber('12345');
// 4) Load chats, send a message
await TdLib.loadChats(25);
const chats = JSON.parse(await TdLib.getChats(25));
await TdLib.sendMessage(chats[0].id, 'Hello from React Native!');Example app
A full Telegram-like reference client ships under example/: login wizard, chat list with live updates, chat view with reactions, reply, typing indicator, photo previews, pagination.
git clone https://github.com/vladlenskiy/react-native-tdlib.git
cd react-native-tdlib/example && npm install
cd ios && pod install && cd ..
npx react-native run-ios # or run-androidDocumentation
- Getting Started → — install, auth flow, first chat.
- API Reference → — all 51 methods, grouped.
- Cookbook → — practical recipes (messages, reactions, files, options, typing).
- Events → —
tdlib-updatestream, update types cheatsheet. - Platform Parity → — how iOS and Android stay in sync.
Contributing
Pull requests welcome. See CONTRIBUTING.md for the local workflow.
Before submitting: npm test must pass and the example app must build on both platforms.
Community & support
- 🐛 Bugs / feature requests → GitHub Issues
- 💬 Questions / discussion → GitHub Discussions
- 🐦 Updates → @vladlensk1y on Twitter/X
- ✉️ Private → [email protected]
Sponsor this project
Open source takes time. If this library saves you a week of wrestling with cmake and TDLib internals, consider supporting development:
Sponsors are listed in the CHANGELOG and on the repository homepage.
License
MIT © Vladlen Kaveev and contributors. TDLib itself is licensed under the Boost Software License.
