Auth Session
Read the same Supabase session from popup, side panel, options, content UI, or background without relying on page cookies or localStorage.
Check session on mount
import { auth } from "@/integrations/supabase";
const user = await auth.getUser(); // { id, email } | null
const signedIn = await auth.isAuthenticated();
const session = await auth.getSession(); // full token + user + expiryListen for changes
auth.onChange reports sign-in, sign-out, and token refresh so surfaces can update authenticated UI without polling.
import { auth } from "@/integrations/supabase";
auth.onChange((session) => {
if (session.isAuthenticated) showApp(); else showLogin();
});Sign in and sign up
The same helper owns email/password and OAuth flows:
import { auth } from "@/integrations/supabase";
// Email + password
await auth.signIn(email, password);
await auth.signUp(email, password);
// Google OAuth (opens in a browser tab and resumes automatically)
await auth.signInWithOAuth("google");
// Sign out everywhere
await auth.signOut();For local services, OAuth redirects, and production deployment, continue with Supabase Backend.
