Universal Authentication Client for JavaScript

Stop WritingAuth CodeOver and Over

AuthFlow handles login, token management, and API calls automatically. Works everywhere - browsers, Node.js, React Native, and SSR environments.

npm install @jmndao/auth-flow
Before AuthFlow
// Manual token management
localStorage.setItem('token', response.data.token);

// Manual refresh logic
if (error.status === 401) {
  // Handle token refresh...
  const refreshToken = localStorage.getItem('refresh');
  // More boilerplate code...
}

// Manual cookie handling
document.cookie = `token=${token}; path=/`;
With AuthFlow
const auth = createAuthFlow(config);

await auth.login(credentials);

// Just works - automatic refresh, storage, etc.
const data = await auth.get('/api/profile');
TypeScript
Secure
Zero Config
Universal
Production-Ready Features

Everything You Need for
Modern Auth

Stop reinventing the wheel. AuthFlow provides all the features you need for secure, scalable authentication out of the box.

Universal Compatibility

Works seamlessly across browsers, Node.js, React Native, and SSR environments. One codebase, every platform.

Automatic Token Management

Smart token refresh with request queuing prevents race conditions. Never worry about expired tokens again.

Framework Agnostic

Integrates perfectly with Next.js, React, Vue, Express, and any JavaScript framework. No vendor lock-in.

Multiple Storage Options

Choose from localStorage, cookies, memory, or custom adapters. Optimal storage selection based on environment.

Production Ready

Built-in caching, monitoring, retry logic, circuit breakers, and comprehensive error handling for production workloads.

TypeScript First

Complete type safety with intelligent autocomplete. Zero dependencies in the core library for minimal bundle size.

Zero dependencies • Universal compatibility • TypeScript first

Experience the Flow

See how authentication flows seamlessly across different environments and use cases.

Basic Setup

Quick StartBrowser

Get started with AuthFlow in just a few lines of code

Next.js Server Actions

Server ActionsNext.js

Seamless server-side authentication with automatic cookie management

Cookie-Based Authentication

Cookie AuthUniversal

Secure authentication using httpOnly cookies

Enhanced Client (v2)

Advanced FeaturesProduction

Production-ready features like caching, retries, and monitoring

Route Protection Middleware

MiddlewareFramework

Protect your routes with built-in middleware

basic-setup.ts
import { createAuthFlow } from '@jmndao/auth-flow';

const auth = createAuthFlow({
  baseURL: 'https://api.yourapp.com',
  endpoints: {
    login: '/auth/login',
    refresh: '/auth/refresh'
  },
  tokens: {
    access: 'accessToken',
    refresh: 'refreshToken'
  }
});

// Login user
const user = await auth.login({ 
  email: 'user@example.com', 
  password: 'password' 
});

// Make authenticated requests
const profile = await auth.get('/api/profile');
const settings = await auth.post('/api/settings', data);
{}
<>
/>
[]
()
&&
||
=>
Performance & Developer Experience

Built for Scale & Speed

AuthFlow delivers exceptional performance while keeping your development experience smooth and productive.

0
Configuration Lines
100%
Flow Coverage
3
Steps to Auth
Platform Flow
Package Size
302 kB
Unpacked Size
Tree Shaking
Enabled
Import What You Need
API Coverage
100%
TypeScript Types
Rich feature set • MIT licensed • Production ready

Ready to Experience
Effortless Auth Flow?

Join thousands of developers building secure, scalable applications with seamless authentication flows. Get started in minutes, not hours.

Quick Start
# npm install @jmndao/auth-flow
# Ready to use in 3 lines of code