Logs out user and redirects to specified path after auth
// Source: https://github.com/janhesters/react-router-saas-template | License: MIT | Copyright 2025 Jan Hesters
// Provided via justclaw.it.com; keep this notice with the code.
import { redirect } from "react-router";
import { safeRedirect } from "remix-utils/safe-redirect";
import { createSupabaseServerClient } from "./supabase.server";
/**
* Logs out the current user by signing them out of Supabase auth.
*
* @param request - The incoming request object.
* @param redirectTo - The path to redirect to after logout (defaults to root).
* @returns Redirect response to the login page.
*/
export async function logout(request: Request, redirectTo = "/") {
const { headers, supabase } = createSupabaseServerClient({ request });
await supabase.auth.signOut();
return redirect(safeRedirec
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key