How nodejs/nan works
NAN is a header-only C++ compatibility layer for Node.js native add-ons, presenting a stable, newer-style interface over changing V8 and Node APIs. The principal workflow is that an add-on includes nan.h and uses its wrappers to expose JavaScript-facing methods and work with V8 values; NAN selects version-specific implementations where needed. The graph also preserves major documented capabilities such as callbacks, handles, persistent references, and object wrapping. Source excerpts are partial, so unsampled subsystem relationships are omitted rather than inferred.
Main entry points: nan.h NAN facade · nan_callbacks.h Callback abstractions · nan_new.h Value factories · nan_maybe_43_inl.h Modern maybe API
Components 21
Addon API
- NAN facade
nan.h - Callback abstractions
nan_callbacks.h - Modern callbacks
nan_callbacks_12_inl.h - Legacy callbacks
nan_callbacks_pre_12_inl.h
Compatibility Layer
- Modern implementations
nan_implementation_12_inl.h - Legacy implementations
nan_implementation_pre_12_inl.h - Value factories
nan_new.h - Modern maybe API
nan_maybe_43_inl.h - Legacy maybe API
nan_maybe_pre_43_inl.h - Property helper
nan_define_own_property_helper.h
Values and State
- Type converters
nan_converters.h - JSON helpers
nan_json.h - String and bytes
nan_string_bytes.h - Typed array contents
nan_typedarray_contents.h - Modern persistent refs
nan_persistent_12_inl.h - Legacy persistent refs
nan_persistent_pre_12_inl.h - Weak references
nan_weak.h
Addon Utilities
- Object wrapping
nan_object_wrap.h - Script origin
nan_scriptorigin.h
Other components
- Addon developer
- Node.js and V8
Connections 21
- Addon developer → NAN facade: includes
README.md - NAN facade → Callback abstractions: includes
nan.h - NAN facade → Value factories: includes
nan.h - NAN facade → Modern maybe API: includes
nan.h - NAN facade → Legacy maybe API: includes
nan.h - NAN facade → Type converters: includes
nan.h - NAN facade → JSON helpers: includes
nan.h - NAN facade → String and bytes: includes
nan.h - NAN facade → Typed array contents: includes
nan.h - NAN facade → Modern persistent refs: includes
nan.h - NAN facade → Legacy persistent refs: includes
nan.h - NAN facade → Weak references: includes
nan.h - NAN facade → Object wrapping: includes
nan.h - NAN facade → Script origin: includes
nan.h - Callback abstractions → Modern callbacks: selects by version
nan_callbacks.h - Callback abstractions → Legacy callbacks: selects by version
nan_callbacks.h - Value factories → Modern implementations: selects by version
nan_new.h - Value factories → Legacy implementations: selects by version
nan_new.h - Modern maybe API → Property helper: uses helper
nan_maybe_43_inl.h - Legacy maybe API → Property helper: uses helper
nan_maybe_pre_43_inl.h - NAN facade → Node.js and V8: abstracts APIs
README.md