SecureStartKit
SecurityFeaturesPricingDocsBlogChangelog
Sign inBuy Now
Home/Glossary/OAuth
Authentication

OAuth

Also known as: OAuth 2.1, social login, federated authentication

Definition

OAuth is an open standard for delegated authorization, used in Supabase apps as federated sign-in via providers like Google, GitHub, and Apple. The user authenticates with the provider, the provider returns an authorization code to a callback route, and the server exchanges the code for a Supabase session via PKCE.

What is OAuth in a Supabase context?

OAuth lets a user prove their identity using an existing account at a trusted provider. The Supabase client calls signInWithOAuth({ provider: 'google' }), which redirects to Google. Google authenticates the user, then redirects back to a callback route on your app with an authorization code. Your callback exchanges that code for a Supabase session.

How do you secure the OAuth callback?

Three rules. First, configure the dashboard's Redirect URLs allowlist to exact paths in production, not ** wildcards. Second, validate any next query parameter the callback uses for post-auth redirects: it must start with a single / and never with // (which browsers interpret as protocol-relative). Third, fail closed on PKCE exchange errors. Never let the redirect proceed if the code exchange threw.

What does the OAuth flow look like in Next.js?

A Server Action calls signInWithOAuth, the user lands on the provider, the provider redirects to /auth/callback?code=..., and a Route Handler calls exchangeCodeForSession(code). The handler sets httpOnly session cookies via @supabase/ssr and redirects the user to their dashboard.

Learn more

  • Supabase OAuth, Magic Links, MFA in Next.js
  • Supabase Auth in Next.js App Router

Related terms

  • PKCEPKCE (Proof Key for Code Exchange) is the OAuth 2.1 flow that prevents authorization-code interception by browser-based clients. The client generates a verifier, hashes it into a challenge, sends the challenge with the auth request, and presents the original verifier at the code-exchange step. An attacker who steals the code alone cannot complete the exchange.
  • Magic linkA magic link is a one-time email token that exchanges for a Supabase session when clicked. Magic links are single-use, rate-limited (default one per 60 seconds per user), expire after one hour, and use the PKCE flow when configured with token-hash email templates.
  • @supabase/ssr@supabase/ssr is the official Supabase package for server-side authentication in Next.js, SvelteKit, and other SSR frameworks. It manages JWT storage in httpOnly cookies, handles the OAuth and magic-link callback cookie writes, and exposes createServerClient and createBrowserClient helpers for each context.
← Back to full glossary
SecureStartKit

The security-first Next.js SaaS template. Auth, payments, and everything you need to launch - with backend-only data access, Zod validation on every input, and built-in optimization for AI coding agents.

Summarize with AI

Product

  • Security
  • Features
  • Pricing
  • FAQ
  • Docs
  • About

Use Cases

  • For Indie Hackers
  • For Solo Developers
  • Fintech SaaS
  • Internal Tools
  • Healthtech SaaS

Free Tools

  • All Tools
  • RLS Policy Generator
  • Security Checklist
  • Security Headers
  • JWT Decoder
  • JWT Generator
  • CORS Config Generator
  • JSON to Zod Converter
  • API Key Generator
  • Stripe Webhook Verifier
  • Stripe Fee Calculator
  • SaaS Pricing Calculator
  • Tech Stack Costs
  • OG Image Preview

Compare

  • All comparisons
  • vs ShipFast
  • vs Makerkit
  • vs Supastarter
  • vs Divjoy
  • vs Nextbase
  • One-time vs subscription

Resources

  • Blog
  • Glossary
  • Security Patterns
  • Changelog
  • Contact
  • Privacy
  • Terms

More from the same maker

  • AppScreenshotStudio
  • QueryScope
  • FrictionScope
  • MCP Hunter
  • BookIllustrationAI
  • MyCVCraft
  • StyleMyFade

© 2026 SecureStartKit. All rights reserved.

Built with SecureStartKit