© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3w ago•
15 replies
jkwok678

Unable to exchangeCodeForSession

auth
Hey, I've been working on a workflow to convert anonymous users to permanent ones with
const { data, error: authError } = await supabase.auth.updateUser(
        {
          email: formData.email,
          password: formData.password,
        },
        {
          emailRedirectTo: `${window.location.origin}/auth/callback`,
        },
      );
const { data, error: authError } = await supabase.auth.updateUser(
        {
          email: formData.email,
          password: formData.password,
        },
        {
          emailRedirectTo: `${window.location.origin}/auth/callback`,
        },
      );

But when I get to my route with nextJS
const { searchParams, origin } = new URL(request.url);
const code = searchParams.get("code");

  const code = searchParams.get("code");
    const { error } = await supabase.auth.exchangeCodeForSession(code);
const { searchParams, origin } = new URL(request.url);
const code = searchParams.get("code");

  const code = searchParams.get("code");
    const { error } = await supabase.auth.exchangeCodeForSession(code);

This fails when I am updating the user email and password, but it doesn't fail when I verify my email after signing up.
I'm testing on the same browser each time.
I logged out the authError and saw -
❌ Exchange Code Error: PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.
Auth Failed. Params: {
  code: '162db2f3-fa6d-4816-8b24-e8eb37083fc0',
  token_hash: null,
  type: null
}
❌ Exchange Code Error: PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.
Auth Failed. Params: {
  code: '162db2f3-fa6d-4816-8b24-e8eb37083fc0',
  token_hash: null,
  type: null
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

exchangeCodeForSession not working
SupabaseSSupabase / help-and-questions
3mo ago
exchangeCodeForSession doesn´t work in production
SupabaseSSupabase / help-and-questions
14mo ago
Supabase.auth.exchangeCodeForSession doesn't persist session
SupabaseSSupabase / help-and-questions
3y ago
Session from `supabase.auth.exchangeCodeForSession()` not persisting
SupabaseSSupabase / help-and-questions
3y ago