Socket
Book a DemoInstallSign in
Socket

react-native-tdlib

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-tdlib

React Native wrapper for TDLib

1.3.1
latest
npmnpm
Version published
Weekly downloads
44
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

React Native TDLib

NPM Version License npm Downloads

⚠️ Note: This library is currently under development, and contributions are welcome! If you'd like to help improve the library, feel free to submit issues or pull requests.

react-native-tdlib is a React Native bridge for the TDLib (Telegram Database Library) that allows developers to interact with Telegram's API seamlessly in their React Native applications.

Installation

npm install react-native-tdlib
# or
yarn add react-native-tdlib

Available Methods

The library provides the following methods for interacting with Telegram's TDLib. These are grouped into Base API and High-Level API for easier understanding.

High-Level API

These methods simplify common tasks and abstract away low-level details.

MethodDescription
startTdLibStarts the TDLib service with required parameters.
loginInitiates login with a phone number.
verifyPhoneNumberVerifies a phone number using an OTP code.
verifyPasswordVerifies the account password for two-factor authentication.
getAuthorizationStateFetches the current authorization state.
getProfileRetrieves the profile information of the logged-in user.
logoutLogs out of the current session.

These methods offer low-level access to TDLib's functionalities.

MethodDescription
td_json_client_createCreates a new TDLib client instance.
td_json_client_executeSynchronously executes a TDLib request.
td_json_client_sendSends a TDLib request asynchronously.
td_json_client_receiveReceives a TDLib response with a timeout.

Example Usage

High-Level API Example

// Start TDLib
await TdLib.startTdLib({
  api_id: 123456,
  api_hash: 'your_api_hash'
});

// Login with phone number
await TdLib.login({
  countrycode: '+1',
  phoneNumber: '1234567890'
});

// Verify phone number
await TdLib.verifyPhoneNumber('12345'); // Replace with the OTP you received

// Verify password (Optional)
await TdLib.verifyPassword('password');

// Get current profile
const profile = await TdLib.getProfile();
console.log(profile);

Base API Example

const tdLibParameters = {
    '@type': 'setTdlibParameters',
    parameters: {
        database_directory: 'tdlib',
        use_message_database: true,
        use_secret_chats: true,
        api_id: 123456, // Replace with your API ID
        api_hash: 'your_api_hash', // Replace with your API Hash
        system_language_code: 'en',
        device_model: 'React Native',
        system_version: '1.0',
        application_version: '1.0',
        enable_storage_optimizer: true,
    },
};

// Send TDLib parameters
TdLib.td_json_client_send(tdLibParameters);

Features

  • Direct communication with TDLib for Telegram API interactions.
  • Cross-platform support for iOS and Android.
  • Easy-to-use methods for common TDLib operations, such as setting parameters, sending requests, and receiving updates.

📝 TODO

  • Move Prebuilt Library out of Repository
  • Complete Android Method Implementations
  • Improve Documentation
  • Make a list of methods to implement

Example Project

This repository includes an example directory with a fully functional React Native project that demonstrates how to use the library. You can explore the example project to see how the library is integrated and used.

Running the Example

  • Clone the repository:
git clone https://github.com/vladlenskiy/react-native-tdlib.git
cd react-native-tdlib/example
  • Install dependencies:
npm install
# or
yarn install
  • Run the app:
npx react-native run-android   # For Android
npx react-native run-ios       # For iOS

Keywords

react-native

FAQs

Package last updated on 08 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.