Contributing
April 17, 2026 · View on GitHub
Thanks for wanting to contribute! This library is open-source and community-driven.
Project layout
.
├── index.js / index.d.ts ← JS bridge + public types
├── ios/ ← Objective-C++ native module + xcframework
├── android/ ← Kotlin/Java native module + jniLibs
├── __tests__/ ← Jest tests for the JS bridge
├── example/ ← Reference app (Telegram-like client)
└── docs/ ← User documentation
Local development
One-time setup
# Root (library)
npm install
# Example app
cd example
npm install
cd ios && pod install && cd ..
Running the example
cd example
npm start # start Metro
npx react-native run-ios # in another tab
npx react-native run-android # or for Android
The example app auto-links the library from the repo root via metro.config.js watchFolders — no symlinks, no npm link.
Running the tests
npm test
The Jest suite verifies the JS ↔ native contract: every exposed method must be on both the JS index.js and the native module.
Typechecking
# library
npx tsc --noEmit -p tsconfig.json # (if one exists) — otherwise skip
# example app
cd example && npx tsc --noEmit
Adding a new method
-
Native
- Add an
RCT_EXPORT_METHODon iOS (ios/TdLibModule.mm). - Add a matching
@ReactMethodon Android (android/…/TdLibModule.java). - Keep signatures identical across platforms (same argument order and types). If promising a
TdRawResult, usesendTdLibRequestWithRawResulton iOS andresult.putString("raw", gson.toJson(object))on Android.
- Add an
-
JS glue
- Add the method to
index.js. - Add typed signature to
index.d.ts. - Add the method name to the Jest mock in
__tests__/index.test.js.
- Add the method to
-
Docs
- Add a row to the right table in
docs/api-reference.md. - Consider a recipe in
docs/cookbook.mdif the call is non-obvious.
- Add a row to the right table in
-
Example
- Add a test row in
example/src/MethodsTestExample.tsxso the Debug tab exercises it.
- Add a test row in
Style
- Don't add dependencies. The library is zero-dep on purpose.
- Don't leak native errors — always map to a stable JS error code and message.
- Prefer fire-and-forget for anything called from hot paths (list rendering, typing) — heavy waiting is a lag waiting to happen.
Releasing
Maintainer only:
npm version patch # or minor / major
git push --follow-tags
npm publish
The prebuilt binaries in ios/Libraries/tdjson/ and android/src/main/jniLibs/ are checked into the repo and shipped via the npm tarball — no separate build step needed at publish time.
Code of conduct
Be kind. We review PRs on our own time.