authentifier
v1.0.0
Published
Simple authentication library for Firebase, Supabase, and AppWrite
Downloads
111
Maintainers
Readme
Authentifier
One line of code to add authentication to any app.
A lightweight, zero-config authentication library that works with Firebase, Supabase, and AppWrite using a unified API.
npm install authentifier
npx authentifier # Generate configFeatures
- Zero Config - Run CLI, paste credentials, done
- Unified API - Same code for all providers
- TypeScript - Full type support out of the box
- Tree-shakable - Only bundle what you use
- Browser Ready - Works in any frontend framework
Supported Providers
| Provider | Status | |----------|--------| | 🔥 Firebase | Production Ready | | ⚡ Supabase | Production Ready | | 📦 AppWrite | Production Ready |
Quick Start
1. Install
npm install authentifier2. Generate Config
npx authentifierChoose your provider and enter your credentials. The CLI generates auth.config.js for you.
3. Use It
import auth from './auth.config.js';
// Sign up
const result = await auth.signUp('John', '[email protected]', 'password123');
// Sign in
const login = await auth.signIn('[email protected]', 'password123');
// Get user
const user = auth.getCurrentUser();
// Check if logged in
auth.isAuthenticated(); // true
// Sign out
await auth.signOut();CLI Usage
Interactive Mode
npx authentifierQuick Mode
# Firebase
npx authentifier --firebase --apiKey=xxx --authDomain=xxx --projectId=xxx --appId=xxx
# Supabase
npx authentifier --supabase --url=xxx --anonKey=xxx
# AppWrite
npx authentifier --appwrite --projectId=xxxConfiguration
The CLI generates this config file for you. You don't need to write it manually.
Firebase (auth.config.js)
import { Auth } from 'authentifier';
const auth = new Auth({
service: 'firebase',
config: {
apiKey: 'AIzaSy...',
authDomain: 'myapp.firebaseapp.com',
projectId: 'my-app',
appId: '1:123:web:abc'
}
});
export default auth;Supabase (auth.config.js)
import { Auth } from 'authentifier';
const auth = new Auth({
service: 'supabase',
config: {
url: 'https://xyzcompany.supabase.co',
anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
}
});
export default auth;AppWrite (auth.config.js)
import { Auth } from 'authentifier';
const auth = new Auth({
service: 'appwrite',
config: {
endpoint: 'https://cloud.appwrite.io/v1',
projectId: 'my-project-id'
}
});
export default auth;API Reference
Auth Class
const auth = new Auth({ service, config });Methods
| Method | Description |
|--------|-------------|
| signUp(name, email, password) | Create new user account |
| signIn(email, password) | Sign in existing user |
| signOut() | Sign out current user |
| getCurrentUser() | Get logged in user or null |
| isAuthenticated() | Check if user is logged in |
Returns
{
user: {
id: string;
name: string;
email: string;
}
}Error Handling
try {
const result = await auth.signUp('John', '[email protected]', 'password123');
} catch (error) {
if (error.message.includes('email-already-exists')) {
// Handle duplicate email
} else if (error.message.includes('weak-password')) {
// Handle weak password
}
}Direct Adapter Usage
import { FirebaseAdapter, SupabaseAdapter, AppWriteAdapter } from 'authentifier';
const adapter = new FirebaseAdapter(firebaseConfig);
const result = await adapter.signUp('John', '[email protected]', 'password');TypeScript
import { Auth, AuthService, SignUpResult, User } from 'authentifier';
const auth = new Auth({
service: 'firebase' as AuthService,
config: firebaseConfig
});
const result: SignUpResult = await auth.signUp('John', '[email protected]', 'pass');
const user: User = result.user;Bundle Size
| Provider | Minified + Gzipped | |----------|-------------------| | All (bundled) | ~84 KB | | Firebase only | ~40 KB | | Supabase only | ~30 KB | | AppWrite only | ~15 KB |
Requirements
- Node.js 14+ (for CLI and SSR)
- Modern browsers (Chrome, Firefox, Safari, Edge)
License
MIT
