A utility library for JavaScript and Typescript.
Remeda is a functional utility library built from the ground up for TypeScript, offering over 150 data manipulation functions with first-class type support. Unlike older libraries like Lodash or Ramda, Remeda provides dual invocation styles: you can call functions data-first for immediate execution with IDE autocomplete, or data-last for functional composition in pipes—without importing separate curried versions.
The library was created to solve the autocomplete problem inherent in pure data-last libraries like Ramda, where IDEs can't suggest parameters until you pass the data. With 3.7+ million weekly downloads, Remeda has become the go-to choice for teams that want functional programming ergonomics without sacrificing developer experience. Every function includes comprehensive JSDoc documentation, and the type system provides maximal specificity—often narrowing union types or inferring exact object shapes.
Remeda's standout feature is lazy evaluation in pipes. When you chain operations like filter, map, and take, the library automatically detects opportunities to skip unnecessary iterations, deferring work until the final result is needed. This happens transparently without special syntax. The library is fully tree-shakable, ships with both ESM and CommonJS modules, and maintains 100% test coverage for both runtime behavior and type correctness.
Developers use Remeda in production applications ranging from data transformation pipelines to React component logic. It's particularly effective in TypeScript codebases where type safety and readability are priorities, replacing ad-hoc utility functions and reducing the need for complex manual type guards.
import * as R from 'remeda';
// Data-first style with immediate autocomplete
const users = [
{ id: 1, name: 'Alice', age: 28, active: true },
{ id: 2, name: 'Bob', age: 34, active: false },
{ id: 3, name: 'Charlie', age: 28, active: true },
{ id: 2, name: 'Bob', age: 34, active: false }, // duplicate
];
const result = R.pipe(
users,
R.filter(u => u.active),
R.unique(), // removes duplicate Bob
R.map(u => R.pick(u, ['name', 'age'])),
R.groupBy(u => u.age),
R.mapValues(group => group.length)
);
// Type: Record<number, number>
// Result: { 28: 2, 34: 0 } - active users grouped by age
// Data-last style for reusable transformations
const getActiveNames = R.pipe(
R.filter<typeof users[number]>(u => u.active),
R.map(u => u.name),
R.take(5)
);
const names = getActiveNames(users);
// Type: string[]
// Result: ['Alice', 'Charlie']
// Async pipeline with error handling
const processFiles = R.pipeAsync(
async (paths: string[]) => Promise.all(paths.map(readFile)),
R.compact, // remove failed reads (nullish values)
R.flatMap(content => content.split('\n')),
R.unique()
);
async function readFile(path: string) {
try {
return await fetch(path).then(r => r.text());
} catch {
return null;
}
}Data transformation pipelines: Chain operations like filtering, mapping, grouping, and sorting arrays or objects in a readable left-to-right flow. Use lazy evaluation to process large datasets efficiently, stopping iteration early when you only need the first N results.
API response normalization: Transform nested API responses into flat structures using flatMap, pick, and omit. Extract error details with pick(error, ['data', 'status']) while maintaining precise TypeScript types for the resulting object shape.
Form data processing: Validate and transform user input by piping through functions like compact (remove nullish values), unique (deduplicate), and mapValues (transform object properties). The dual API style lets you write imperative validation logic where needed and functional transformations for complex flows.
State management utilities: Build Redux selectors or React hooks that derive state using groupBy, indexBy, or pathOr for safe nested access. Compose multiple transformations in pipe while preserving type narrowing through each step.
Async data workflows: Use pipeAsync to chain Promise-returning operations like file I/O, database queries, or HTTP requests. Combine with compact to filter out failed results and flatMap to merge paginated responses into single arrays.
npm install remedapnpm add remedabun add remeda