remix-utils is a comprehensive collection of modular utility functions designed to extend the capabilities of applications built with the Remix framework and React Router. As of version 9.3.1, this library offers a wide array of tools covering both server-side and client-side concerns. Its utilities range from advanced data loading patterns like `promiseHash` for concurrent fetches and `timeout` for resilient API calls, to server-side middleware for handling common web challenges such as client IP detection, CORS, CSRF protection, request ID generation, and server timing. Client-side enhancements include functions like `cacheAssets` for efficient browser caching of build artifacts. The package maintains an `active` and consistent release cadence, frequently pushing out minor and patch updates to introduce new features, resolve bugs, and ensure seamless compatibility with the evolving Remix and React Router ecosystems. A key distinguishing factor is its highly modular design, which allows developers to selectively install and import only the specific utilities needed, thereby keeping bundles lean. Many components can even be installed via a shadcn-like registry for simplified management. This approach differentiates it from monolithic utility libraries, promoting a more focused and performant integration within Remix projects.
npm install remix-utilsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates using `promiseHash` to concurrently fetch multiple data sources in a Remix loader and applies `timeout` to an external API call to prevent long-running requests from blocking the response, handling potential `TimeoutError`s gracefully.
Migrate session validation to use `@standard-schema/spec` as introduced in v8.8.0, or implement custom validation logic. Review the v8.x to v9.x upgrade guides.
Always consult the release notes and upgrade guides in the documentation (e.g., `./docs/v6-to-v7.md`) before performing major version upgrades.
Always refer to the package documentation or the `package.json`'s `exports` field to determine the correct subpath for the specific utility you intend to use.
Check the documentation for each utility you use and ensure all listed optional dependencies (e.g., `@oslojs/crypto` for CSRF, `is-ip` for client IP detection) are explicitly installed in your project.
Refactor middleware logic to avoid direct mutation of the context. Instead, return new context objects or use other patterns for state management within middleware pipelines.
Ensure `cacheAssets` is placed exclusively within your Remix `entry.client.ts` or `entry.client.tsx` file to guarantee it runs in a browser environment.
Correct the import statement to use the specific subpath, e.g., `import { promiseHash } from 'remix-utils/promise';` or `import { cacheAssets } from 'remix-utils/cache-assets';`.Identify the missing dependency by checking the documentation for the specific utility. Install it using `npm add <dependency-name>`, e.g., `npm add @oslojs/crypto`.
Refactor your session management. For typed sessions, consider migrating to patterns supported by `@standard-schema/spec` as introduced in v8.8.0, or use standard Remix session storage.
Move the `cacheAssets()` call exclusively into your `app/entry.client.ts` or `app/entry.client.tsx` file.