Skip to content

Commit

Permalink
docs: Add example to README (#569)
Browse files Browse the repository at this point in the history
* docs: Add example to README

* add languages
  • Loading branch information
mrousavy authored Feb 23, 2025
1 parent 753f939 commit 55f654b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ It consists of two parts:
- [**react-native-nitro-modules**](packages/react-native-nitro-modules): The core C++ library powering all nitro modules
- [**nitrogen**](packages/nitrogen): A code-generator for nitro module library authors

## Example

Declaration (TypeScript):
```ts
export interface Math extends HybridObject {
add(a: number, b: number): number
}
```

Implementation (C++, Swift or Kotlin):
```cpp
class HybridMath: public HybridMathSpec {
public:
double add(double a, double b) {
return a + b;
}
}
```
Usage (TypeScript):
```ts
const math = NitroModules.createHybridObject<Math>('Math')
const result = math.add(5, 3)
```

## Installation

Install [react-native-nitro-modules](https://npmjs.org/react-native-nitro-modules) from npm:
Expand Down

0 comments on commit 55f654b

Please sign in to comment.