> For the complete documentation index, see [llms.txt](https://the-sheet.gitbook.io/the-sheet-v2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://the-sheet.gitbook.io/the-sheet-v2/docs/resources/react-native-module-codegen.md).

# React Native Module Codegen

A brief overview of how React Native codegen handles stuff

* I asked AI for this, so it's worth looking into the official docs of codegen

## 1. The JavaScript Layer (getEnforcing)

This is the "Request."

* Where: Your TypeScript Spec file.
* The Code: TurboModuleRegistry.getEnforcing('GalaxyGate')
* Fragility: If this string doesn't match the name registered in the Native layer, JS will look for a key that doesn't exist.

## 2. The Native Layer (Registration)

This is the "Provider."

* iOS: Inside your .mm (Objective-C++) file, you have a macro: return "GalaxyGate"; (or RCT\_EXPORT\_MODULE(GalaxyGate)).
* Android: Inside your GalaxyGateModule.java, you return the name: public String getName() { return "GalaxyGate"; }
* Fragility: This is what "announces" the module to the app on boot-up. If this is UniversePortal but JS asks for GalaxyGate, the app will find nothing.

## 3. The Discovery Layer (Autolinking)

This is the "Bridge Builder" we discussed.

* The File: GalaxyGate.podspec
* The package.json: "name": "galaxy-gate"
* The codegenConfig: "name": "GalaxyGateSpec"
* Fragility: If you rename the .podspec file but don't update the s.name inside the file, CocoaPods will get confused and might not link the source files correctly.

## Naming

* Two specific names:
  * GalaxyGateSpec (The "Blueprint"): Name for generated C++ and Java code
  * GalaxyGate (The "ID"): Runtime string for handshakes between JS and Native

| Layer                    | Name Pattern            | Example File/String         |
| ------------------------ | ----------------------- | --------------------------- |
| **Your Source File**     | `Native<Name>.ts`       | `NativeGalaxyGate.ts`       |
| **Codegen Output (C++)** | `Native<Name>Spec.h`    | `NativeGalaxyGateSpec.h`    |
| **Java Interface**       | `Native<Name>Spec.java` | `NativeGalaxyGateSpec.java` |
| **The Handshake ID**     | `<Name>`                | `GalaxyGate`                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://the-sheet.gitbook.io/the-sheet-v2/docs/resources/react-native-module-codegen.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
