Complete React authentication solution for QwickApps applications. Zero-configuration Supabase integration with beautiful UI components and comprehensive auth workflows.
- 🔐 Zero Config Auth - Built-in Supabase integration, just provide credentials
- ⚛️ React Hooks -
useAuth,useIsAuthenticated,useHasRole - 🎨 Beautiful UI - Complete auth workflows with Material-UI components
- 🛡️ Route Protection -
AuthRoute,RouteGuard,AccessGuardcomponents - 🚀 TypeScript - Full type safety with comprehensive interfaces
- 📱 Responsive - Mobile-first design with all screen sizes supported
- 🎭 Social Login - Google, GitHub, Facebook integration ready
- 🔄 Session Management - Automatic token refresh and persistence
npm install @qwickapps/auth-clientimport { AuthProvider } from '@qwickapps/auth-client';
function App() {
return (
<AuthProvider
config={{
supabaseUrl: process.env.REACT_APP_SUPABASE_URL,
supabaseKey: process.env.REACT_APP_SUPABASE_ANON_KEY,
appName: "My App"
}}
>
<MyApp />
</AuthProvider>
);
}import { useAuth, useIsAuthenticated } from '@qwickapps/auth-client';
function MyComponent() {
const { user, signIn, signOut, loading } = useAuth();
const isAuthenticated = useIsAuthenticated();
if (loading) return <div>Loading...</div>;
if (!isAuthenticated) {
return (
<button onClick={() => signIn({ email: 'user@example.com', password: 'password' })}>
Sign In
</button>
);
}
return (
<div>
<h1>Welcome {user.name}!</h1>
<button onClick={signOut}>Sign Out</button>
</div>
);
}import { LoginPage, RegisterPage, PasswordResetPage } from '@qwickapps/auth-client';
import { Routes, Route } from 'react-router-dom';
function AppRoutes() {
return (
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route path="/register" element={<RegisterPage />} />
<Route path="/reset-password" element={<PasswordResetPage />} />
{/* Your other routes */}
</Routes>
);
}import { AuthRoute, RouteGuard } from '@qwickapps/auth-client';
function ProtectedRoutes() {
return (
<Routes>
{/* Route-level protection */}
<Route
path="/dashboard"
element={
<AuthRoute requireAuth>
<Dashboard />
</AuthRoute>
}
/>
{/* Role-based protection */}
<Route
path="/admin"
element={
<AuthRoute requireRoles={['admin']}>
<AdminPanel />
</AuthRoute>
}
/>
</Routes>
);
}The main authentication provider that handles all auth state:
<AuthProvider
config={{
supabaseUrl: string,
supabaseKey: string,
appName?: string,
redirectUrls?: {
afterSignIn?: string,
afterSignOut?: string,
afterSignUp?: string,
passwordReset?: string,
},
features?: {
socialLogin?: boolean,
emailVerification?: boolean,
passwordReset?: boolean,
registration?: boolean,
}
}}
onAuthStateChange?: (state) => void
onError?: (error) => void
>
{children}
</AuthProvider>Ready-to-use auth pages with beautiful UI:
// Login page
<LoginPage
title="Welcome Back"
subtitle="Sign in to your account"
onSuccess={(session) => navigate('/dashboard')}
showSocialLogin={true}
registerUrl="/register"
/>
// Register page
<RegisterPage
title="Create Account"
subtitle="Join our platform today"
onSuccess={(user) => navigate('/dashboard')}
requireName={true}
signInUrl="/login"
/>
// Password reset
<PasswordResetPage
title="Reset Password"
subtitle="Enter your email to reset your password"
backToLoginUrl="/login"
/>Multiple ways to protect your routes:
// Simple auth requirement
<AuthRoute requireAuth>
<Dashboard />
</AuthRoute>
// Role-based access
<AuthRoute requireRoles={['admin', 'moderator']}>
<AdminPanel />
</AuthRoute>
// Component-level protection
<RouteGuard
authState={{ user, loading: false }}
requiredRoles={['admin']}
fallback={<AccessDenied />}
>
<SensitiveComponent />
</RouteGuard>
// Access control for individual elements
<AccessGuard user={user} requireRoles={['admin']}>
<AdminButton />
</AccessGuard>Main authentication hook:
const {
// State
user, // Current user or null
session, // Current session or null
loading, // Auth operation in progress
error, // Last auth error
initialized, // Auth provider ready
// Actions
signIn, // Sign in with email/password
signUp, // Register new user
signOut, // Sign out current user
resetPassword, // Send password reset email
updateProfile, // Update user profile
refreshSession, // Refresh current session
signInWithProvider, // Social login
clearError, // Clear current error
} = useAuth();const isAuthenticated = useIsAuthenticated();
const hasAdminRole = useHasRole('admin');
const hasAnyModRole = useHasAnyRole(['admin', 'moderator']);For advanced use cases, access the Supabase provider directly:
import { SupabaseAuthProvider } from '@qwickapps/auth-client';
const authProvider = new SupabaseAuthProvider({
supabaseUrl: 'your-url',
supabaseKey: 'your-key'
});
// Access Supabase client
const supabaseClient = authProvider.getClient();Enable social login providers:
<AuthProvider
config={{
supabaseUrl: 'your-url',
supabaseKey: 'your-key',
features: {
socialLogin: true
}
}}
>
{/* Social login will be available in LoginPage */}
</AuthProvider>Handle authentication errors:
<AuthProvider
config={authConfig}
onError={(error) => {
console.error('Auth error:', error);
toast.error(error.message);
}}
onAuthStateChange={(state) => {
if (state.user && !state.loading) {
analytics.identify(state.user.id);
}
}}
>
{children}
</AuthProvider>Full TypeScript support with comprehensive type definitions:
import type {
AuthUser,
AuthSession,
ClientAuthConfig,
AuthContextValue,
LoginPageProps,
} from '@qwickapps/auth-client';
// Type-safe configuration
const config: ClientAuthConfig = {
supabaseUrl: process.env.REACT_APP_SUPABASE_URL!,
supabaseKey: process.env.REACT_APP_SUPABASE_ANON_KEY!,
};
// Type-safe event handlers
const handleAuthStateChange = (state: ClientAuthState) => {
if (state.user) {
console.log('User signed in:', state.user.email);
}
};Set up your environment variables:
REACT_APP_SUPABASE_URL=your_supabase_project_url
REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_keyThis package depends on:
@qwickapps/react-framework- UI components and theming@qwickapps/auth-backend- Shared auth types and utilities@supabase/supabase-js- Supabase client- React 16.8+ with hooks support
- Material-UI for styling
If you're upgrading from the old framework auth system:
// OLD - Framework auth
import { AuthProvider } from '@qwickapps/react-framework';
<AuthProvider user={user} authConfig={{ enableBuiltInRoutes: true }}>
{children}
</AuthProvider>
// NEW - Auth client
import { AuthProvider } from '@qwickapps/auth-client';
<AuthProvider config={{ supabaseUrl, supabaseKey }}>
{children}
</AuthProvider>Copyright (c) 2025 QwickApps.com. All rights reserved. This software is proprietary and confidential.