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.
npm install harshil-authVerified import paths — ran on the pinned version, not inferred.
Shows basic initialization with AuthProvider and usage of useAuth hook for login/logout.
Update imports: `import { AuthProvider, useAuth } from 'harshil-auth'` instead of default import.Replace `withAuth(Component)` with `useAuth()` inside component or use Next.js middleware.
Ensure your project uses Next.js 13+ with App Router enabled.
Set `NEXT_PUBLIC_API_URL` environment variable or pass `apiUrl` prop.
Use `'use client'` directive or wrap in a client component boundary.
Use `import harshilAuth from 'harshil-auth'` (default) or check docs for named exports.
Run `npm install harshil-auth` and ensure import path is correct.
Pass `config={{ apiUrl: process.env.NEXT_PUBLIC_API_URL }}` to AuthProvider.