• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License
    • Account API
    • Team Account API
    • Authentication API

Authentication API | Remix Supabase SaaS Kit

A quick introduction to the Authentication API in Makerkit

The Authentication API is a set of functions that help you authenticate users in your application. It is built on top of the Supabase authentication system and provides a simple way to authenticate users in your application.

tsx
import { redirect } from '@remix-run/react';
import { LoaderFunctionArgs } from '@remix-run/node';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
export async function loader(args: LoaderFunctionArgs) {
const client = getSupabaseServerClient(args.request);
const auth = await requireUser(client);
// check if the user needs redirect
if (auth.error) {
return redirect(auth.redirectTo);
}
// user is authed!
const user = auth.data;
// return your data
return {
data: {} // your data here,
};
}

If the user needs MFA and is not yet verified, the redirect function will redirect the user to the MFA verification page. This is why it is important to check the redirectTo property in the response.