Appearance
Crate Module Map
Fresh 🌱A navigation map of the neon crate's public modules - what each one holds and when you reach for it. Use this to find the right module; the guides on this site explain how to use the pieces in practice.
This is an orientation map, not the full API
For exhaustive, signature-level reference (every struct, trait, and method), consult the generated rustdoc API documentation for the neon crate. This page exists to point you at the right module quickly.
The modules
| Module | Holds | Reach for it when you... |
|---|---|---|
prelude | The common imports (Context, Handle, Js* types, JsResult, NeonResult). | Start any file: use neon::prelude::*;. |
context | Context trait, FunctionContext, ModuleContext, Cx, TaskContext, and friends. | Need value constructors, arguments, exports, or the runtime handle (cx). |
types | The Js* value types: JsNumber, JsString, JsObject, JsArray, JsFunction, JsPromise, JsBox, JsTypedArray, plus the extract submodule. | Work with any JavaScript value from Rust. |
object | The Object trait and object property access. | Get and set properties on objects and arrays. |
handle | Handle and related root/handle machinery. | Hold and pass references to JS values. |
result | JsResult, NeonResult, the ResultExt trait (or_throw), and throw types. | Return values, propagate errors, or throw exceptions. |
event | Channel, and event-scheduling types. | Schedule JS work from another thread (async, callbacks). |
thread | Thread-local storage helpers for the JS environment. | Stash per-thread state tied to the runtime. |
reflect | Reflection helpers. | Do lower-level reflective operations. |
meta | Build/version metadata constants for the crate. | Inspect Neon's own version/feature metadata. |
sys | The low-level, unsafe Node-API FFI surface. | (Advanced) Drop below the safe API to raw N-API. Rarely needed. |
How the modules relate
flowchart TD
PRELUDE[prelude: import everything] --> CONTEXT[context: cx, the runtime handle]
CONTEXT --> TYPES[types: JsNumber, JsString, JsObject, ...]
CONTEXT --> RESULT[result: JsResult, throw, or_throw]
TYPES --> OBJECT[object: get / set properties]
TYPES --> HANDLE[handle: Handle / Root]
CONTEXT --> EVENT[event: Channel for async]
EVENT --> THREAD[thread: per-thread state]
CONTEXT -.advanced.-> SYS[sys: raw Node-API FFI]
style PRELUDE fill:#10b981,color:#fff
style CONTEXT fill:#6366f1,color:#fff
style SYS fill:#f59e0b,color:#fffWhere to go for usage
| You want to... | Start at |
|---|---|
| Build JS values | Primitive Types, Objects, Arrays |
| Export and read functions | Functions, Export Functions SOP |
| Call back into JS | Calling JavaScript from Rust |
| Run async / threaded work | Async Tasks, Promises & Channels |
| Throw and handle errors | Error Handling |
| Embed native data | Boxed Native Data (JsBox) |
| Work with binary data | Buffers & Typed Arrays |
Almost everything routes through context
The context module gives you cx, and cx is how you reach the rest. If you are unsure which module a method lives on, check context and types first - see the Context Methods cheat sheet.