https://github.com/bugra9/cpp.js
Bind C++ to JavaScript with no extra code. (WebAssembly & React Native)
https://github.com/bugra9/cpp.js
bindings cpp emscripten javascript react-native swig wasm webassembly
Last synced: 7 months ago
JSON representation
Bind C++ to JavaScript with no extra code. (WebAssembly & React Native)
- Host: GitHub
- URL: https://github.com/bugra9/cpp.js
- Owner: bugra9
- License: mit
- Created: 2023-01-01T10:53:44.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-20T21:46:45.000Z (12 months ago)
- Last Synced: 2024-10-21T02:12:01.155Z (12 months ago)
- Topics: bindings, cpp, emscripten, javascript, react-native, swig, wasm, webassembly
- Language: JavaScript
- Homepage: https://cpp.js.org
- Size: 7.36 MB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Getting Started
·
Integrate Into Existing Project
·
C++ Bindings
·
Showcase## Basic Usage
**src/index.js**
```js
import { initCppJs, Factorial } from './native/Factorial.h';await initCppJs();
const factorial = new Factorial(99999);
const result = factorial.calculate();
console.log(result);
```**src/native/Factorial.h**
```c++
class Factorial {
private:
int number;public:
Factorial(int num) : number(num) {}int calculate() {
if (number < 0) return -1;int result = 1;
for (int i = 2; i <= number; i++) {
result *= i;
}
return result;
}
};
```## Prerequisites
To begin building your project with Cpp.js, you’ll first need to install a few dependencies:- Docker
- Node.js version 18 or higher
- CMake version 3.28 or higher (only required for Mobile development)
- Xcode (only required for iOS development)
- Cocoapods (only required for iOS development)## Create a New Project
To set up a new cpp.js project with a minimal starter structure, execute the following command in your terminal:
```sh
npm create cpp.js@latest
```## License
[MIT](https://github.com/bugra9/cpp.js/blob/main/LICENSE)Copyright (c) 2025, Buğra Sarı