MODULE 02LESSON 03 · 11:20

Authentication

Email/password, magic links, and social sign-in.

SYSTEM_PLAYBACK_ACTIVEVideo placeholder

Ask for "add login" and Lovable wires up sign-up, sign-in, password reset, protected routes, and a session provider. Google and Apple sign-in are built in — no OAuth app setup required.

/The auth surface

  • 01Sign up / sign in pages: Prebuilt, styled to match your theme, ready to customize.
  • 02Protected routes: Wrap any route in the authenticated layout and it redirects logged-out users automatically.
  • 03Session hook: A React hook exposes the current user everywhere in your app.
  • 04Server-side identity: Server functions receive the authenticated user and enforce RLS on their behalf.
Security note

Never store user roles on the profile table. Use a separate user_roles table with a SECURITY DEFINER helper function — Lovable does this by default and will refuse to publish if you break the pattern.

/Common flows to ask for

  • 01"Add email + password login": The simplest starting point — email verification included.
  • 02"Add Google sign-in": One extra prompt, zero config.
  • 03"Require login for /dashboard": Moves the route into the protected layout.