Registry / auth-security / harshil-auth

harshil-auth

JSON →
library2.6.9jsnpmunverified

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-auth
INSTALL
IMPORT
SIG · HARSHIL-AUTH
H
harshil-auth
auth-securityjavascriptv2.6.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import harshilAuth from 'harshil-auth'
const harshilAuth = require('harshil-auth')
ESM-only since v2. Use dynamic import() if CommonJS required.
AuthProvider
import { AuthProvider } from 'harshil-auth'
import AuthProvider from 'harshil-auth'
Named export, not default.
useAuth
import { useAuth } from 'harshil-auth'
import useAuth from 'harshil-auth'
Named export for React hook.
withAuth
import { withAuth } from 'harshil-auth'
import withAuth from 'harshil-auth'
Named export for HOC pattern.

Shows basic initialization with AuthProvider and usage of useAuth hook for login/logout.

import harshilAuth from 'harshil-auth'; import { AuthProvider, useAuth } from 'harshil-auth'; // Initialize in app layout function App({ Component, pageProps }) { return ( <AuthProvider config={{ apiUrl: process.env.API_URL ?? 'http://localhost:3000/api' }}> <Component {...pageProps} /> </AuthProvider> ); } // In a component function Profile() { const { user, login, logout } = useAuth(); if (!user) return <button onClick={login}>Sign In</button>; return <button onClick={logout}>Sign Out</button>; } export default App;
Debug
Known issues
breakingVersion 2.0.0 changed from default export to named exports for hooks (AuthProvider, withAuth).
fix
Update imports: `import { AuthProvider, useAuth } from 'harshil-auth'` instead of default import.
affects: >=2.0.0
deprecatedThe `withAuth` HOC is deprecated in v2.5.0; use `useAuth` hook or server-side middleware.
fix
Replace `withAuth(Component)` with `useAuth()` inside component or use Next.js middleware.
affects: >=2.5.0
gotchaRequires Next.js 13+ App Router; does not support Pages Router or older Next.js versions.
fix
Ensure your project uses Next.js 13+ with App Router enabled.
affects: all
gotchaThe `config` object passed to AuthProvider must include an `apiUrl` that points to your authentication backend.
fix
Set `NEXT_PUBLIC_API_URL` environment variable or pass `apiUrl` prop.
affects: all
gotchaClient-side only; cannot be used in server components.
fix
Use `'use client'` directive or wrap in a client component boundary.
affects: all
Errors
Common errors & fixes
TypeError: harshilAuth is not a function
Importing default export when using ESM import incorrectly.
fix
Use `import harshilAuth from 'harshil-auth'` (default) or check docs for named exports.
Module not found: Can't resolve 'harshil-auth'
Package not installed or incorrect import path.
fix
Run `npm install harshil-auth` and ensure import path is correct.
Error: No API URL provided in AuthProvider config
Missing `apiUrl` configuration.
fix
Pass `config={{ apiUrl: process.env.NEXT_PUBLIC_API_URL }}` to AuthProvider.
Upgrade
Version history
2.6.9latest on npm
Audit
Dependencies
nextrequiredpeer dependency for server-side auth features
reactrequiredpeer dependency for client-side hooks
react-domrequiredpeer dependency for rendering
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
harshil-auth — npm install harshil-auth · libregistry