SecureStartKit
SecurityFeaturesPricingDocsBlogChangelog
Sign inBuy Now
Home/Glossary/PKCE
Authentication

PKCE(Proof Key for Code Exchange)

Also known as: Proof Key for Code Exchange, PKCE flow

Definition

PKCE (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.

What is PKCE?

PKCE is the OAuth flow used by clients that cannot keep a secret, which includes browsers and mobile apps. Before initiating the OAuth redirect, the client generates a random code_verifier and a code_challenge (SHA-256 hash of the verifier). The challenge travels with the authorization request; the verifier stays in cookie storage on the originating client.

When the authorization server returns the auth code, the client posts both the code AND the verifier back. The server hashes the verifier and compares to the stored challenge. Mismatched values reject the exchange.

Why does PKCE matter for Next.js apps?

The authorization code travels through URL parameters, referer headers, browser history, and server logs. Any of those can leak the code. Without PKCE, an attacker with the code can complete the exchange themselves. With PKCE, the code is useless without the verifier, and the verifier never appears in any URL.

When is PKCE the default?

In Supabase, @supabase/ssr uses PKCE for all OAuth and magic-link flows automatically. The older implicit flow that sent tokens directly in URL fragments is deprecated.

Learn more

  • Supabase OAuth, Magic Links, MFA in Next.js

Related terms

  • OAuthOAuth 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.
  • 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