Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Functional Programming
  3. NeverThrow

NeverThrow

MITTypeScriptv8.2.0

A TypeScript/JavaScript library providing a Result type for type-safe error handling without exceptions.

GitHubGitHub
7.6k stars152 forks0 contributors

What is NeverThrow?

Neverthrow is a library for JavaScript and TypeScript that provides a `Result` type for type-safe error handling. It allows developers to represent operations that can succeed or fail as explicit `Ok` or `Err` values, eliminating the need for thrown exceptions. This makes error handling predictable, composable, and fully type-checked.

Target Audience

TypeScript and JavaScript developers building applications where robust, explicit error handling is critical, such as backend services, data processing pipelines, or any system requiring high reliability.

Value Proposition

Developers choose Neverthrow because it brings Rust-like error handling to JavaScript/TypeScript, offering compile-time safety, fluent APIs for chaining operations, and utilities to seamlessly integrate with existing promise-based or exception-throwing code.

Overview

Type-Safe Errors for JS & TypeScript

Use Cases

Best For

  • Building TypeScript applications with compile-time error safety
  • Replacing try/catch blocks with explicit, chainable error handling
  • Wrapping third-party libraries that throw exceptions into safe Result types
  • Chaining multiple fallible operations without nested conditionals
  • Handling asynchronous errors in a synchronous-style API
  • Ensuring all errors are explicitly handled via linting rules

Not Ideal For

  • Projects where rapid prototyping and minimal code overhead are prioritized over type safety
  • Teams deeply entrenched in standard promise-based error handling with async/await and try/catch
  • Applications with globally managed errors where explicit per-operation checking feels unnecessarily verbose
  • Environments with extreme performance constraints where object wrapper overhead is unacceptable

Pros & Cons

Pros

Type-Safe Error Encoding

Encapsulates success and failure in TypeScript types, eliminating uncaught exceptions and enabling compile-time checks, as shown in the Result<T, E> generic signatures throughout the API.

Fluent Composition API

Provides combinators like map, andThen, and orElse for chainable operations, allowing complex error flows without nested conditionals, similar to promises but with error awareness.

Seamless Async Integration

ResultAsync wraps Promise<Result> and is thenable, enabling synchronous-style error handling for asynchronous code without manual await chaining, detailed in the asyncAndThen and asyncMap methods.

Third-Party Exception Safety

Utilities like fromThrowable and fromAsyncThrowable convert exception-throwing functions into Result-returning ones, making it safe to integrate with libraries that use throw, as demonstrated in the wrapping examples.

Cons

Functional Programming Mindset Required

Demands familiarity with concepts like monads and combinators, which can be a steep learning curve for developers used to imperative JavaScript, evident in methods like andThen and safeTry using generators.

Boilerplate in Simple Cases

For straightforward error handling, using Results can be more verbose than try/catch, as seen in the safeTry example which requires a generator function for implicit error returns.

Dependency and Performance Overhead

Adds a third-party library to core error handling, with potential performance costs from object wrappers and method calls, though not explicitly benchmarked in the README.

Frequently Asked Questions

Quick Stats

Stars7,636
Forks152
Contributors0
Open Issues49
Last commit5 months ago
CreatedSince 2019

Tags

#functional-programming#result-type#async-await#type-safety#rust-inspired#typescript#javascript-library#error-handling

Built With

J
JavaScript
T
TypeScript

Included in

Functional Programming6.0k
Auto-fetched 6 hours ago

Related Projects

Fantasy LandFantasy Land

Specification for interoperability of common algebraic structures in JavaScript

Stars10,239
Forks370
Last commit1 year ago
SanctuarySanctuary

:see_no_evil: Refuge from unsafe JavaScript

Stars3,054
Forks93
Last commit1 year ago
FlutureFluture

🦋 Fantasy Land compliant (monadic) alternative to Promises

Stars2,493
Forks82
Last commit2 years ago
purifypurify

Functional programming library for TypeScript - https://gigobyte.github.io/purify/

Stars1,602
Forks63
Last commit7 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub