{"id":18408,"library":"harshil-auth","title":"harshil-auth","description":"Custom authentication library for Next.js and React applications. Current stable version 2.6.9, actively maintained with regular updates. Designed for Next.js 13+ (App Router) and React 18+. Ships TypeScript types. Key differentiator: simple integration with Next.js projects, but minimal documentation and community adoption compared to alternatives like NextAuth.js.","status":"active","version":"2.6.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","auth","nextjs","react","typescript"],"install":[{"cmd":"npm install harshil-auth","lang":"bash","label":"npm"},{"cmd":"yarn add harshil-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add harshil-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for server-side auth features","package":"next","optional":false},{"reason":"peer dependency for client-side hooks","package":"react","optional":false},{"reason":"peer dependency for rendering","package":"react-dom","optional":false}],"imports":[{"note":"ESM-only since v2. Use dynamic import() if CommonJS required.","wrong":"const harshilAuth = require('harshil-auth')","symbol":"default","correct":"import harshilAuth from 'harshil-auth'"},{"note":"Named export, not default.","wrong":"import AuthProvider from 'harshil-auth'","symbol":"AuthProvider","correct":"import { AuthProvider } from 'harshil-auth'"},{"note":"Named export for React hook.","wrong":"import useAuth from 'harshil-auth'","symbol":"useAuth","correct":"import { useAuth } from 'harshil-auth'"},{"note":"Named export for HOC pattern.","wrong":"import withAuth from 'harshil-auth'","symbol":"withAuth","correct":"import { withAuth } from 'harshil-auth'"}],"quickstart":{"code":"import harshilAuth from 'harshil-auth';\nimport { AuthProvider, useAuth } from 'harshil-auth';\n\n// Initialize in app layout\nfunction App({ Component, pageProps }) {\n  return (\n    <AuthProvider config={{ apiUrl: process.env.API_URL ?? 'http://localhost:3000/api' }}>\n      <Component {...pageProps} />\n    </AuthProvider>\n  );\n}\n\n// In a component\nfunction Profile() {\n  const { user, login, logout } = useAuth();\n  if (!user) return <button onClick={login}>Sign In</button>;\n  return <button onClick={logout}>Sign Out</button>;\n}\n\nexport default App;","lang":"typescript","description":"Shows basic initialization with AuthProvider and usage of useAuth hook for login/logout."},"warnings":[{"fix":"Update imports: `import { AuthProvider, useAuth } from 'harshil-auth'` instead of default import.","message":"Version 2.0.0 changed from default export to named exports for hooks (AuthProvider, withAuth).","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace `withAuth(Component)` with `useAuth()` inside component or use Next.js middleware.","message":"The `withAuth` HOC is deprecated in v2.5.0; use `useAuth` hook or server-side middleware.","severity":"deprecated","affected_versions":">=2.5.0"},{"fix":"Ensure your project uses Next.js 13+ with App Router enabled.","message":"Requires Next.js 13+ App Router; does not support Pages Router or older Next.js versions.","severity":"gotcha","affected_versions":"all"},{"fix":"Set `NEXT_PUBLIC_API_URL` environment variable or pass `apiUrl` prop.","message":"The `config` object passed to AuthProvider must include an `apiUrl` that points to your authentication backend.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `'use client'` directive or wrap in a client component boundary.","message":"Client-side only; cannot be used in server components.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import harshilAuth from 'harshil-auth'` (default) or check docs for named exports.","cause":"Importing default export when using ESM import incorrectly.","error":"TypeError: harshilAuth is not a function"},{"fix":"Run `npm install harshil-auth` and ensure import path is correct.","cause":"Package not installed or incorrect import path.","error":"Module not found: Can't resolve 'harshil-auth'"},{"fix":"Pass `config={{ apiUrl: process.env.NEXT_PUBLIC_API_URL }}` to AuthProvider.","cause":"Missing `apiUrl` configuration.","error":"Error: No API URL provided in AuthProvider config"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}