@briamco/authmagic
v0.1.2
Published
Passwordless authentication using Supabase
Downloads
12
Readme
AuthMagic
A simple, customizable SDK for passwordless authentication using Supabase's Magic Link feature. Built with TypeScript, designed for React. GitHub
✨ Features
- 🔐 Passwordless login via Magic Link
- ✅ Easy integration with existing Supabase client
- 🎨 Customizable login UI template
- ⚡ Lightweight and fast
📦 Installation
npm install authmagicor
yarn add authmagic🚀 Usage
1. Initialize the SDK
Make sure you already have a Supabase client created.
import AuthMagic from "authmagic";
import { supabase } from "./your-supabase-client"; // your existing Supabase client
const authMagic = new AuthMagic(supabase);or
import AuthMagic from "authmagic";
const authMagic = new AuthMagic({
supabaseUrl: 'your-supabase-url',
supabaseKey: 'your-supabase-key'
});2. Use the login component (React)
import { AuthForm } from "authmagic";
import AuthMagic from "authmagic";
import { supabase } from "./your-supabase-client";
const authMagic = new AuthMagic(supabase);
export default function Login() {
return <AuthForm authMagic={authMagic} color="#6366f1" />;
}🧹 Props for AuthForm
| Prop | Type | Default | Description |
|--------------|-----------------|-------------|--------------------------------------|
| authMagic | AuthMagic | Required| Instance of the AuthMagic class |
| color? | string | #6366f1 | Primary button color (hex or CSS) |
| message? | string | Optional| Magic Link sended message |
| redirectTo?| string | Optional| Link to rediect after singup |
🔧 SDK API
authMagic.sendMagicLink(email: string, redirectUrl?: string)Sends a magic link to the provided email.
authMagic.getSession()Returns the current session if exists.
authMagic.signOut()Signs out and reloads the page.
authMagic.isAuthenticated()Returns true if the user is authenticated.
🖌 Customization
You can override styles or create your own UI using the SDK methods. Use the AuthMagic instance directly in your components.
💡 Tip
Don't forget to set the SITE_URL in your Supabase project to support email redirects.
📄 License
MIT License.
