Skip to content

Commit 6119e95

Browse files
mhdawsonruyadorno
authored andcommitted
doc: clarify use of NAPI_EXPERIMENTAL
We've had a few questions about APIs not being available which were related to not having specified `NAPI_EXPERIMENTAL`. Add some additional documentation to explain this common issue: Refs: nodejs/node-addon-api#810 Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #35195 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 6d4ab36 commit 6119e95

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/api/n-api.md

+12
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ listed as supporting a later version.
337337
version 1 but continued to evolve until Node.js 8.6.0. The API is different in
338338
versions prior to Node.js 8.6.0. We recommend N-API version 3 or later.
339339

340+
Each API documented for N-API will have a header named `added in:`, and APIs
341+
which are stable will have the additional header `N-API version:`.
342+
APIs are directly usable when using a Node.js version which supports
343+
the N-API version shown in `N-API version:` or higher.
344+
When using a Node.js version that does not support the
345+
`N-API version:` listed or if there is no `N-API version:` listed,
346+
then the API will only be available if
347+
`#define NAPI_EXPERIMENTAL` precedes the inclusion of `node_api.h`
348+
or `js_native_api.h`. If an API appears not to be available on
349+
a version of Node.js which is later than the one shown in `added in:` then
350+
this is most likely the reason for the apparent absence.
351+
340352
The N-APIs associated strictly with accessing ECMAScript features from native
341353
code can be found separately in `js_native_api.h` and `js_native_api_types.h`.
342354
The APIs defined in these headers are included in `node_api.h` and

0 commit comments

Comments
 (0)