neverthrow

TypeScript library implementing the Result type pattern from Rust/ML languages. Instead of throwing exceptions, functions return Result<T, E> which is either Ok(value) or Err(error) — forcing callers to explicitly handle both success and failure. Provides a lightweight (< 5KB) alternative to Effect for typed error handling. Includes ResultAsync for Promise-based code. Eliminates try/catch and makes error types visible in function signatures.

Evaluated Mar 06, 2026 (0d ago) v8.x
Homepage ↗ Repo ↗ Developer Tools typescript error-handling result-type rust-result functional type-safe no-throw
&#9881; Agent Friendliness
69
/ 100
Can an agent use this?
&#128274; Security
99
/ 100
Is it safe for agents?
&#9889; Reliability
91
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
88
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
92
Secret Handling
100

Local library — no network access. Zero dependencies. MIT licensed. <5KB bundle impact.

⚡ Reliability

Uptime/SLA
100
Version Stability
88
Breaking Changes
85
Error Recovery
90
AF Security Reliability

Best When

You want typed error handling in TypeScript without the full complexity of Effect — a minimal Result type that makes all error cases explicit.

Avoid When

You need advanced features like structured concurrency, dependency injection, or streams — use Effect instead.

Use Cases

  • Replace try/catch error handling with typed Results in TypeScript to make all failure cases explicit in function signatures
  • Build agent tool functions that return Result<ToolOutput, ToolError> forcing agents to handle failures explicitly rather than catching untyped exceptions
  • Create railway-oriented programming pipelines using andThen/mapErr for chaining operations that can fail at any step
  • Convert Promise-based async operations to ResultAsync for typed async error handling without try/catch
  • Document all possible failure modes of a function in its return type — making the function's error contract visible to callers

Not For

  • Applications requiring comprehensive error recovery, retry logic, and dependency injection — use Effect for full functional programming
  • Teams without TypeScript — neverthrow's value is entirely in TypeScript's type system
  • Simple scripts where try/catch is adequate — neverthrow adds ceremony for simple operations

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Local library — no authentication.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

neverthrow is MIT open source. Free for personal and commercial use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Calling .value on an Err result throws at runtime — always call .isOk() or match() before accessing .value; TypeScript types help prevent this but unannotated code can bypass checks
  • ResultAsync wraps Promise<Result<T,E>> — forgetting to await ResultAsync before chaining leads to type errors about Promise not having .andThen method
  • combining/collecting multiple Results uses combine() or combineWithAllErrors() — forgetting these helpers leads to verbose manual Result unwrapping in array operations
  • neverthrow does NOT automatically catch thrown exceptions — if a function inside .andThen throws, it propagates as an exception, not as an Err; use ResultAsync.fromPromise() to safely wrap throwing code
  • The .match() method is recommended for handling both cases — using if/else with .isOk() works but TypeScript's narrowing doesn't refine the error type as cleanly
  • Interop with APIs that throw (most Node.js and browser APIs) requires wrapping in Result.fromThrowable() or ResultAsync.fromPromise() — not all third-party code can be cleanly wrapped

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for neverthrow.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered