Skip to content
/ cpp.js Public

Bind C++ to JavaScript with no extra code. (WebAssembly & React Native)

License

Notifications You must be signed in to change notification settings

bugra9/cpp.js

Folders and files

NameName
Last commit message
Last commit date
Jan 17, 2025
Jan 19, 2025
Apr 13, 2025
Apr 9, 2025
Jul 30, 2023
Mar 21, 2024
Aug 17, 2024
Dec 9, 2024
Jan 8, 2023
Jan 8, 2023
Jan 5, 2025
Jan 15, 2025
Oct 27, 2024
Apr 13, 2025
Jan 19, 2025
Dec 22, 2024

Repository files navigation

Next.js logo

Cpp.js

Bind C++ to JavaScript with no extra code.
WebAssembly & React Native

NPM version License Discussions Issues
CodeQL Linux Build Macos Build Windows Build

Basic Usage

src/index.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

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:

npm create cpp.js@latest

License

MIT

Copyright (c) 2025, Buğra Sarı