remix-auth is a TypeScript-first, strategy-based authentication library designed for Remix and React Router applications. Inspired by Passport.js, it provides full server-side authentication capabilities built on the Web Fetch API, ensuring compatibility with modern web standards. The library is currently stable at version 4.2.0 and maintains an active release cadence, frequently introducing new features, bug fixes, and documentation improvements. Key differentiators include its robust TypeScript support, extensible strategy pattern (with separate npm packages for various authentication flows like Form, OAuth2, etc.), and seamless integration with Remix's server-side action and loader functions, allowing developers to implement custom authentication logic. It dropped direct React Router requirements in v4.0.0, simplifying its core and making it more adaptable.
npm install remix-authVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core setup of `remix-auth` with `FormStrategy`, including session storage configuration, `Authenticator` instantiation, strategy registration, and integration into Remix `action` and `loader` functions for user login and authentication checks.
Review the official migration guide or documentation for v4.0.0 to adapt your `Authenticator` and strategy configurations. Ensure your Remix application and associated packages are up to date.
Refactor your codebase to use ES module import syntax (`import ... from '...'`) instead of CommonJS `require()` calls for `remix-auth` and its associated strategies.
Always check the `remix-auth` version supported by each strategy package's documentation or `package.json` before installation. Install compatible versions to avoid runtime errors.
If you are using Remix v2, ensure your `remix-auth` package is at least v3.6.0. It is recommended to upgrade to the latest stable version of `remix-auth` for optimal compatibility and features.
Ensure you correctly initialize `Authenticator` with an instance of `SessionStorage` provided by `@remix-run/node` or a custom implementation. Configure session cookie options, including a secure `secrets` array, correctly.
Update all `remix-auth` imports (and other ESM packages) in your project to use ES module syntax: `import { Authenticator } from 'remix-auth';`. Ensure your `tsconfig.json` and `package.json` are configured for ESM output if necessary.Verify that you have correctly instantiated `Authenticator` with `new Authenticator(sessionStorage)` and that the instance is correctly exported and imported where `authenticate` is called. Double-check for typos.
Ensure that you have called `authenticator.use(new MyStrategy(...), 'my-strategy')` to register your strategy with the correct name before attempting to authenticate with it.
Ensure that the `request` object from your Remix `loader` or `action` function is correctly passed as the second argument to `authenticator.authenticate()` or `authenticator.isAuthenticated()`.