rn-turbo-generator
v0.1.5
Published
A CLI to scaffold React Native TurboModules with codegen-ready structure
Maintainers
Readme
🚀 TurboModule Generator CLI for React Native
A tiny CLI that creates the basic file structure for a React Native TurboModule. You answer a few questions, and the tool scaffolds everything you need to get started.
No heavy logic. No opinions. Just clean TurboModule bones 🦴 that you can flesh out your own way.
✨ What this package does
Asks you a few simple questions in the terminal
Generates:
- TurboModule spec file
- Android native module boilerplate
- Package + registration files
Creates dummy methods only
Leaves full control to you to customize logic later
Think of it as a TurboModule starter kit 🧰
📦 Installation
npm install -g rn-turbo-generatoror
npx rn-turbo-generator🧠 Questions you’ll answer
When you run the CLI, you’ll be prompted with:
TurboModule name (PascalCase)
Default method name
Platform support (android / ios / both)
Android package name (e.g. com.example.app)Example answers 👇
Module Name: NativeLocalStorage
Method Name: clear
Platform: android
Package Name: com.nativelocalstorage🗂️ What gets generated
After answering the questions, the CLI creates:
/turbo-modulesfolder with TurboModule spec- Android native module files
- Android package class
- Basic dummy method implementation
⚠️ Important This tool does not write business logic. It only creates structure so you can move fast 🏃♂️💨
🧩 Required manual step (Very important)
You must add codegenConfig to your package.json.
📍 Place it just before the dependencies key
"codegenConfig": {
"name": "RnTurboModules",
"type": "modules",
"jsSrcsDir": "src/turbo-modules",
"android": {
"javaPackageName": "com.YOUR_PACKAGE_NAME"
}
}This tells React Native how to generate native bindings 🧬
⚙️ Generate codegen artifacts
Run the following commands:
cd android
./gradlew generateCodegenArtifactsFromSchemaThis step generates all required TurboModule bindings automatically ⚡
🧩 Register the package (Android)
Open MainApplication.kt and add your package manually:
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here
add(NativeLocalStoragePackage())
}📌 The package file is already generated 📌 You only need to register it
🧪 Using the TurboModule in your app
Now you can import and use your TurboModule:
import NativeLocalStorage from './turbo-modules/NativeLocalStorage';
NativeLocalStorage?.clear();🎉 That’s it. Your TurboModule is alive.
🛠 What you should do next
- Replace dummy methods with real logic
- Add more methods to the spec file
- Implement native logic in Android / iOS
- Ship blazing fast native features 🚀
🧠 Notes
- Works only with New Architecture enabled
- Designed for TurboModules
- Android-first, iOS optional
- Clean structure, zero lock-in
💡 Philosophy
“Scaffold fast, customize freely.”
This tool builds the runway. You decide how high the plane flies ✈️
Developed by Mohan Gupta ❤️␠␠
Happy hacking 💙␠␠
If TurboModules were LEGO, this would be the base plate 🧱❤️
