Skip to main content
Get started with better-result in seconds using your preferred package manager.

Package Manager Installation

For new projects, use the interactive CLI to get everything set up:
This interactive setup will:
  1. Install the better-result package
  2. Optionally fetch source code via opensrc for better AI context
  3. Install the adoption skill + /adopt-better-result command for AI agents
  4. Optionally launch your agent to start refactoring
The adoption skill helps AI coding agents (OpenCode, Claude, Codex) guide you through converting existing error handling to better-result patterns.

Requirements

TypeScript 5.0+ is required. better-result uses modern TypeScript features for type safety.

TypeScript Configuration

For the best experience, enable strict mode in your tsconfig.json:
tsconfig.json

Runtime Support

better-result is ESM-only and works with:
  • Node.js 16.0+
  • Bun (all versions)
  • Deno (with npm specifier: npm:better-result)
  • Browsers (via bundlers like Vite, webpack, or esbuild)
CommonJS is not supported. If you need CommonJS, you’ll need to transpile the package yourself.

Verify Installation

Create a simple test file to verify everything works:
test.ts
Run it:
You should see:

Migrating from v1?

If you’re upgrading from better-result v1.x to v2.x, use the migration CLI:
This will guide you through the breaking changes and help automate the migration process.
See the Migration Guide for detailed information about what changed in v2.

Next Steps

Now that better-result is installed, let’s build something:

Quickstart Tutorial

Build your first Result-based application with a step-by-step guide