About this project
# Born React Native Godot
React Native Godot lets you embed the Godot Engine inside React Native apps. It was created by [Born](https://born.com) and developed by [Migeran](https://migeran.com) in collaboration.
## Main Features
* Supports Android and iOS, built on [LibGodot](https://github.com/migeran/libgodot).
* Used in production by Born, serving millions of users.
* Start, stop, and restart the Godot Engine; each restart can load a different Godot project.
* Pause and resume the running Godot instance.
* Godot runs on a separate thread, keeping UI and React Native JavaScript thread responsive.
* Embed the Godot main window and its subwindows on the same or different screens.
* Access the full Godot API from TypeScript/JavaScript: instantiate objects, call methods, get/set properties, connect to signals, and pass JS callables to Godot.
## Getting Started with the Example App
The [example app](example/) demonstrates the main features. After installing prerequisites (e.g., via ASDF for Node, Java, Gradle, Ruby) and exporting the Godot samples (`./export_godot_GodotTest.sh android|ios`, etc.), download prebuilt libraries and run on iOS or Android as usual with `yarn ios` / `yarn android`. A convenience `update_deps.sh` script handles setup.
## Your First React Native Godot App
1. Install from npm: `yarn add @borndotcom/react-native-godot`
2. Download prebuilt LibGodot packages: `yarn download-prebuilt` (not distributed via npm; this allows custom builds).
3. Import and use the view: `import { RTNGodot, RTNGodotView, runOnGodotThread } from "@borndotcom/react-native-godot"`.
4. Add `<RTNGodotView style={...}/>` (defaults to Godot's main window).
5. Initialize Godot on the Godot thread by calling `RTNGodot.createInstance([...])` with command-line args. Key points:
- Use `--display-driver embedded` to embed into React Native.
- On Android, pass a folder path (e.g., `--path /main`) or PCK; on iOS, use `--main-pack` with a pack file. Runtime downloading of Godot apps is recommended for smaller size and easier updates.
6. Stop with `RTNGodot.destroyInstance()` on the Godot thread; pause/resume from the JS main thread via `RTNGodot.pause()` / `RTNGodot.resume()`.
Export your Godot project as PCK or ZIP; the example includes helper scripts.
## Godot API Usage
Access the API via `RTNGodot.API()`:
```typescript
let Godot = RTNGodot.API();
var engine = Godot.Engine;
var vector = Godot.Vector2();
vector.x = 1.0; vector.y = 2.0;
var sceneTree = engine.get_main_loop();
var root = sceneTree.get_root();
```
Connect to signals with `.connect(function() { ... })`, and pass JS functions as Callables to Godot methods (e.g., from a custom Node's GDScript).
## Threading and JavaScript
Godot runs on its own thread. To interact from JavaScript, the library uses [react-native-worklets-core](https://github.com/margelo/react-native-worklets-core) to run workletized JS on the Godot thread via `runOnGodotThread()`. This is the recommended approach; direct calls from the RN main thread are possible but limited (e.g., Scene Tree access is not thread-safe) and object references are not interchangeable between contexts.
## Advanced Topics
* **Custom LibGodot builds**: Clone LibGodot (branch `libgodot_migeran_45`), build with provided scripts, and override download paths via environment variables (e.g., `LIBGODOT_XCFRAMEWORK_PATH`).
* **Debugging native code**: For iOS, build a dev LibGodot and set breakpoints in Xcode; for Android, add symbol directories and optionally symlink the Godot source tree.
* **Remote debugging in Godot Editor**: Pass `--remote-debug tcp://<host>:6007` and use `adb reverse` on Android; set the editor's Remote Host on iOS.
## License
Released under the MIT license.
## Support
Commercial support and development are offered by [Migeran](https://migeran.com). Born is hiring React Native engineers (see [born.com](https://born.com)).
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.