Exporting C++ Class Objects via Node-API and Managing Their Lifecycle
Sample Project Source Code Analysis
The sample project uses a Native C++ template with the Stage model. This analysis focuses on key implementation files for class object export and lifecycle management.
Class Definition and Method Implementation
NapiTest.h Header File
#ifndef __NAPI_TEST_H__
#define __NAPI_TEST_H__
#include "napi/native_ ...
Posted on Thu, 11 Jun 2026 18:28:49 +0000 by itworks
Exporting NAPI Class Objects and Their Lifecycle Management (Part 1)
1. Exporting NAPI Class Objects
OpenHarmony NAPI provides a way to "wrap" C++ classes and instances sothat JS applications can call constructors, methods, and access properties of those classes.
Node.js Node-API also supports exporting class objects.
1.1. Flow of Exporting Class Objects via NAPI
Define a JS class using napi_define_cl ...
Posted on Thu, 07 May 2026 14:48:49 +0000 by bubblocity