Magic Link Auth
Passwordless email authentication with Supabase. Includes login/signup pages, session management, protected route middleware, and email templates.
Next.jsAuthBuilt with Cursor
1.8k
Stars
8.9k
Installs
2
Deps
2
Comments
Install / Copy
npx create-freestack-module magic-link-authCode Preview
index.tsx
import { createClient } from "@supabase/supabase-js";
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export async function middleware(request: NextRequest) {
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
const { data: { session } } = await supabase.auth.getSession();
if (!session && request.nextUrl.pathname.startsWith("/dashboard")) {
return NextResponse.redirect(new URL("/login", request.url));
}
return NextResponse.next();
}
export async function sendMagicLink(email: string) {
const { error } = await supabase.auth.signInWithOtp({ email });
if (error) throw error;
}SE
securityfirst3 days ago
Clean implementation. Added rate limiting on the OTP endpoint and it works well.
IN
indie-hacker1 week ago
Set this up for my SaaS in 30 minutes. No more password reset flows to maintain!
Related Modules
Dashboard Layout
Responsive admin dashboard shell with collapsible sidebar navigation, breadcrumbs, top bar with search, and theme switching. Ready to drop your content into.
3.2kNext.js
Stripe Checkout
Complete Stripe checkout flow with subscription management, webhook handling, and customer portal integration. Includes pricing page component and usage-based billing support.
2.8kNext.js
RBAC System
Role-based access control with middleware enforcement, permission checking hooks, and admin UI for managing roles. Supports hierarchical roles and resource-level permissions.
1.6kNext.js