remix-auth-twitter is an authentication plugin for Remix applications, specifically designed to integrate with the `remix-auth` library. It provides strategies for authenticating users via Twitter's (now X's) OAuth protocols, supporting both the older OAuth 1.0a (via `Twitter1Strategy`) and the newer OAuth 2.0 (via `Twitter2Strategy`). The current stable version is 4.0.0, which aligns with and requires `remix-auth@4`. Releases are primarily driven by compatibility updates with `remix-auth` major versions and changes to the Twitter API (e.g., domain changes from `twitter.com` to `x.com`). A key differentiator is its dual support for both OAuth versions and direct integration into the Remix ecosystem, abstracting much of the OAuth flow complexity.
npm install remix-auth-twitterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure the `Twitter2Strategy` (OAuth 2.0) with `remix-auth`, handle environment variables for credentials, and process the authentication callback to retrieve user information using an external Twitter API client.
Update `remix-auth` to version `^4.2.0` or greater: `npm install remix-auth@latest`.
No code fix is required, but be aware of potential user experience implications for existing authenticated sessions.
Update your code to use `Twitter1Strategy` or `Twitter2Strategy` explicitly. If using OAuth 1.0a, ensure you're using `Twitter1Strategy` and the strategy name `twitter1` (or your custom name).
Inside your `Twitter2Strategy` `verify` callback, use an external Twitter API client (like `twitter-api-v2`) and the provided `accessToken` to query the `/2/users/me` endpoint to retrieve user profile data.
Upgrade to `remix-auth-twitter@2.0.2` or later to ensure these transitive dependencies are updated.
Set `process.env.TWITTER_CLIENT_ID` and `process.env.TWITTER_CLIENT_SECRET` (for OAuth 2.0) or `process.env.TWITTER_CONSUMER_KEY` and `process.env.TWITTER_CONSUMER_SECRET` (for OAuth 1.0a) in your Remix environment (e.g., `.env` file, deployment platform config).
Check the compatibility table in the `remix-auth-twitter` README and ensure your `remix-auth` version matches the requirement for your `remix-auth-twitter` version (e.g., `remix-auth-twitter@4` requires `remix-auth@4`). Run `npm ls remix-auth remix-auth-twitter` to verify installed versions and upgrade as needed.