You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a Next.js 15 (App Router) project and am facing a persistent PGRST106 error when using the EmailProvider with the @next-auth/supabase-adapter. I have followed all documentation and debugging steps but am completely stuck.
The Error:
When I try to sign in with email, the server crashes with a 500 error. The terminal log shows:
My environment variables (NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, AUTH_SECRET, NEXTAUTH_URL) are all set correctly in both .env.local and on Vercel.
I have synced my AUTH_SECRET with the JWT Secret in the Supabase dashboard.
I have successfully run the official SQL schema script to create the users, accounts, sessions, and verification_tokens tables in my public schema.
My public schema is correctly listed in the "Exposed schemas" section of the Supabase API settings.
I have confirmed that a direct database connection from a test API route works perfectly. A simple createClient with the service_role key can successfully select() from the public.users table. This proves my keys and basic connection are correct.
Key Files:
Here is my src/app/api/auth/[...nextauth]/route.ts:
import NextAuth from 'next-auth'
import { SupabaseAdapter } from '@next-auth/supabase-adapter'
import EmailProvider from 'next-auth/providers/email'
const handler = NextAuth({
providers: [
EmailProvider({}),
],
adapter: SupabaseAdapter({
url: process.env.NEXT_PUBLIC_SUPABASE_URL!,
secret: process.env.SUPABASE_SERVICE_ROLE_KEY!,
}),
secret: process.env.AUTH_SECRET,
session: {
strategy: 'jwt',
},
})
export { handler as GET, handler as POST }
Here are my dependencies from package.json: "dependencies": { "@next-auth/supabase-adapter": "^0.2.1", "@supabase/ssr": "^0.4.0", "@supabase/supabase-js": "^2.44.3", "next": "15.3.3", "next-auth": "^5.0.0-beta.19", "react": "^19.0.0-rc-f994737d14-20240522", "react-dom": "^19.0.0-rc-f994737d14-20240522" }
My Question:
Given that a direct connection with the service key works, why would the adapter specifically fail with a PGRST106 schema error? Is this a known issue with these library versions or a subtle Supabase policy I might be missing?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm building a Next.js 15 (App Router) project and am facing a persistent PGRST106 error when using the EmailProvider with the @next-auth/supabase-adapter. I have followed all documentation and debugging steps but am completely stuck.
The Error:
When I try to sign in with email, the server crashes with a 500 error. The terminal log shows:
[next-auth][error][adapter_error_getUserByEmail]
https://next-auth.js.org/errors#adapter_error_getuserbyemail
The schema must be one of the following: public, graphql_public
{ code: 'PGRST106' }
What I Have Already Done:
My environment variables (NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, AUTH_SECRET, NEXTAUTH_URL) are all set correctly in both .env.local and on Vercel.
I have synced my AUTH_SECRET with the JWT Secret in the Supabase dashboard.
I have successfully run the official SQL schema script to create the users, accounts, sessions, and verification_tokens tables in my public schema.
My public schema is correctly listed in the "Exposed schemas" section of the Supabase API settings.
I have confirmed that a direct database connection from a test API route works perfectly. A simple createClient with the service_role key can successfully select() from the public.users table. This proves my keys and basic connection are correct.
Key Files:
Here is my src/app/api/auth/[...nextauth]/route.ts:
Here are my dependencies from package.json:
"dependencies": { "@next-auth/supabase-adapter": "^0.2.1", "@supabase/ssr": "^0.4.0", "@supabase/supabase-js": "^2.44.3", "next": "15.3.3", "next-auth": "^5.0.0-beta.19", "react": "^19.0.0-rc-f994737d14-20240522", "react-dom": "^19.0.0-rc-f994737d14-20240522" }
My Question:
Given that a direct connection with the service key works, why would the adapter specifically fail with a PGRST106 schema error? Is this a known issue with these library versions or a subtle Supabase policy I might be missing?
Thank you for any help you can provide.
Beta Was this translation helpful? Give feedback.
All reactions