{"library":"react-use-auth","title":"react-use-auth","description":"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.","language":"javascript","status":"active","last_verified":"Sat May 09","install":{"commands":["npm install react-use-auth"],"cli":null},"imports":["import { useAuth } from 'react-use-auth'","import { AuthConfig } from 'react-use-auth'","import { Auth0 } from 'react-use-auth/auth0'","import { NetlifyIdentity } from 'react-use-auth/netlify-identity'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// App.tsx\nimport * as React from 'react';\nimport { useAuth, AuthConfig } from 'react-use-auth';\nimport { Auth0 } from 'react-use-auth/auth0';\n\nconst navigate = (to: string) => window.location.assign(to);\n\nfunction App() {\n  const { isAuthenticated, login, logout, user } = useAuth();\n  return (\n    <div>\n      <AuthConfig\n        navigate={navigate}\n        authProvider={Auth0}\n        params={{ domain: process.env.AUTH0_DOMAIN ?? 'example.auth0.com', clientID: process.env.AUTH0_CLIENT_ID ?? '' }}\n      />\n      {isAuthenticated ? (\n        <div>Hello {user?.name}! <button onClick={logout}>Log out</button></div>\n      ) : (\n        <button onClick={login}>Log in</button>\n      )}\n    </div>\n  );\n}\n\nexport default App;","lang":"typescript","description":"Complete setup of Auth0 with useAuth: configures AuthProvider, provides login/logout, and displays user info.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}