Documentation Index
Fetch the complete documentation index at: https://mintlify.com/supermacro/neverthrow/llms.txt
Use this file to discover all available pages before exploring further.
What is NeverThrow?
NeverThrow helps you encode failure into your program using aResult type that represents either success (Ok) or failure (Err). This eliminates the need for try-catch blocks and makes error handling explicit and type-safe.
ResultAsync, which wraps a Promise<Result<T, E>> and gives you the same level of expressivity as a regular Result.
Key features
Type-safe errors
Errors are part of your function signature, making them impossible to ignore and fully type-checked by TypeScript.
Functional patterns
Chain operations with
map, andThen, orElse, and other functional methods for elegant error handling.Async support
ResultAsync is thenable and behaves like a native Promise, but with full Result API access without awaiting.Safe wrapping
Convert throwing functions to Results with
fromThrowable and promises to ResultAsync with fromPromise.Combine results
Aggregate multiple Results with
Result.combine - short-circuits on first error or collects all errors.Generator syntax
Use
safeTry with generator functions for ergonomic error propagation similar to Rust’s ? operator.Next steps
Installation
Install NeverThrow and optional ESLint plugin
Quick start
Learn the basics in under 5 minutes
Core concepts
Deep dive into Result and ResultAsync types
API reference
Browse the complete API documentation
Looking for real-world examples? Check out this production server implementation: parlez-vous/server
Why not just throw?
Throwing and catching exceptions has several drawbacks:- Hidden control flow: Similar to
gotostatements, making code harder to reason about - Unchecked assumptions: You assume the caller will implement
catch, which is a known source of bugs - Unhandled edge cases: One dev throws, another uses the function without knowing it throws, leading to unhappy users
Result, errors are explicit, type-checked, and impossible to ignore.