authln
v0.3.2
Published
AuthLN SDK for authentication with Lightning Network integration
Downloads
41
Readme
AuthLN SDK
AuthLN SDK is a Next.js-based authentication library designed to integrate seamlessly with Lightning Network authentication flows.
📦 Installation
To install the SDK, run:
npm install authln
or with yarn:
yarn add authln
🚀 Usage
1️⃣ Wrap your Next.js app with AuthProvider
Modify your _app.tsx
or layout.tsx
:
import { AuthProvider } from "authln";
export default function App({ Component, pageProps }) {
return (
<AuthProvider>
<Component {...pageProps} />
</AuthProvider>
);
}
2️⃣ Protect a Page
Use ProtectedRoute
to guard pages that require authentication:
import { ProtectedRoute } from "authln";
export default function Dashboard() {
return (
<ProtectedRoute>
<h1>Dashboard</h1>
</ProtectedRoute>
);
}
3️⃣ Access Authentication Data
Use useAuth()
to check the authentication state and user data:
import { useAuth } from "authln";
export default function ProfilePage() {
const { user, isAuthenticated, logout } = useAuth();
return (
<div>
{isAuthenticated ? (
<>
<h1>Welcome, {user?.org.name}</h1>
<button onClick={logout}>Logout</button>
</>
) : (
<p>Please log in.</p>
)}
</div>
);
}
🌍 Environment Variables
To configure the SDK, create a .env.local
file in your Next.js project:
NEXT_PUBLIC_AUTH_API_BASE_URL=https://www.authln-org.com/api/v1/auth
NEXT_PUBLIC_AUTH_API_KEY=your-api-key
🛠️ Development Setup
To run the development server:
npm run dev
# or
yarn dev
Visit http://localhost:3000 to see your Next.js app.
🚀 Deployment
The easiest way to deploy your Next.js app is via Vercel.
📖 Learn More
For additional resources, check out:
🛠 Built with Next.js, TypeScript, and Lightning Network Authentication.