{"id":26487,"library":"tms-auth","title":"TMS Auth","description":"TMS Auth is an authentication library for React/UMI applications, version 1.3.13. It provides hooks and components for handling authentication flows such as login, logout, and permission checks. Built specifically for UMI framework with seamless integration. It ships TypeScript definitions. Last update was several months ago; no known recent active development. Alternative: umi-plugin-auth for UMI-specific setups or generic react-auth-kit.","status":"maintenance","version":"1.3.13","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install tms-auth","lang":"bash","label":"npm"},{"cmd":"yarn add tms-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add tms-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin functionality","package":"umi","optional":false},{"reason":"Peer dependency for React components and hooks","package":"react","optional":false},{"reason":"Peer dependency for DOM rendering","package":"react-dom","optional":false}],"imports":[{"note":"The default export is not available; use named import.","wrong":"import useAuth from 'tms-auth';","symbol":"useAuth","correct":"import { useAuth } from 'tms-auth';"},{"note":"Do not import from subpaths; only the main entry is supported.","wrong":"import { withAuth } from 'tms-auth/src';","symbol":"withAuth","correct":"import { withAuth } from 'tms-auth';"},{"note":"AuthProvider is a named export, not default.","wrong":"import AuthProvider from 'tms-auth';","symbol":"AuthProvider","correct":"import { AuthProvider } from 'tms-auth';"},{"note":"TMSAuth is exported from the package root.","wrong":"import { TMSAuth } from 'tms-auth/TMSAuth';","symbol":"TMSAuth","correct":"import { TMSAuth } from 'tms-auth';"}],"quickstart":{"code":"import { AuthProvider, useAuth } from 'tms-auth';\nimport React from 'react';\n\nfunction LoginButton() {\n  const { login } = useAuth();\n  return (\n    <button onClick={() => login({ username: 'user', password: 'pass' })}>\n      Login\n    </button>\n  );\n}\n\nfunction App() {\n  return (\n    <AuthProvider config={{ tokenKey: 'my_app_token' }}>\n      <LoginButton />\n    </AuthProvider>\n  );\n}\n\nexport default App;","lang":"typescript","description":"Shows minimal setup using AuthProvider and useAuth hook with a login button."},"warnings":[{"fix":"Set tokenKey explicitly in AuthProvider config to match your stored token key.","message":"The tokenKey config option changed from 'token' to 'my_app_token' default after v1.0.0. Existing apps may break if relying on old default.","severity":"gotcha","affected_versions":">=1.0.0 <1.1.0"},{"fix":"Replace withAuth with useAuth hook in functional components.","message":"The withAuth HOC is deprecated in favor of useAuth hook. It may be removed in future versions.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Ensure AuthProvider wraps the entire app or at least the components that need authentication.","message":"AuthProvider must be above any component using useAuth in the component tree; otherwise useAuth throws a runtime error.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Manually call cleanup logic after logout() if needed.","message":"In v1.3.0, the logout function no longer calls a cleanup callback; it only clears the token. Code relying on the callback will break.","severity":"breaking","affected_versions":">=1.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Wrap your component tree with <AuthProvider> at the top level.","cause":"The useAuth hook is called outside of the AuthProvider context.","error":"Error: useAuth must be used within an AuthProvider"},{"fix":"Run 'npm install tms-auth' and ensure tsconfig includes 'node_modules' in typeRoots.","cause":"Missing package installation or TypeScript cannot resolve types.","error":"Cannot find module 'tms-auth' or its corresponding type declarations."},{"fix":"Check that AuthProvider is rendered and passes config correctly.","cause":"The useAuth hook returns an object without login because the provider is missing or misconfigured.","error":"TypeError: login is not a function"},{"fix":"Provide a valid string for tokenKey in AuthProvider config.","cause":"The tokenKey config value is not a string or is undefined.","error":"Error: Invalid tokenKey provided to AuthProvider"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}