React hook for adding authentication to apps with minimal setup. Current stable version 2.0.0 (August 2021) with 2.1.0-14 as prerelease. Supports Auth0, Netlify Identity, and Firebase. Key differentiator: uses XState state machine under the hood, handles SSR, and provides a declarative AuthConfig component. Release cadence is irregular; v2 introduced provider-specific imports to reduce bundle size. Peer dependencies must be installed separately (auth0-js, netlify-identity-widget, or firebase). Ships TypeScript definitions.
npm install react-use-authNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup of Auth0 with useAuth: configures AuthProvider, provides login/logout, and displays user info.
Update imports to provider-specific subpaths, e.g., import { Auth0 } from 'react-use-auth/auth0'.Replace AuthProvider with AuthConfig in all JSX.
Run 'yarn add auth0-js' (or netlify-identity-widget, firebase) as appropriate.
Ensure the import provides a class/constructor: import { Auth0 } from 'react-use-auth/auth0' and pass Auth0 (not a string or object).Place AuthConfig at a high level (e.g., _app.js or gatsby-browser.js) to ensure it renders before any useAuth calls.
Use import { useAuth } from 'react-use-auth' (named import).Upgrade to v2 and change imports to 'react-use-auth/auth0' or downgrade to v1 (not recommended).
Use import { Auth0 } from 'react-use-auth/auth0' and pass Auth0 (the imported class) to AuthConfig.