Supabase SSR / Right way to implement Server Component client

Hey folks,

I'm working on setting up Supabase clients in my NextJS 14 project using Supabase SSR for auth. I'm using middleware to refresh sessions as recommended. I've encountered confusion with different recommendations for server and server component client implementations:

1) Official example for creating a server component, it drops every exception during set and remove, only uses get. (https://github.com/vercel/next.js/blob/canary/examples/with-supabase/utils/supabase/server.ts)

2) Supabase ssr docs, server component client only implements get method, doesn't implement anything else. Server actions client, on the other hand, has all the cookie related methods implemented. (https://supabase.com/docs/guides/auth/server-side/creating-a-client?environment=server-component)

I initially used #1, and it worked fine. However, as I explore #2, it seems like it should work, but it doesn't. #2 throws exceptions saying server components cant set cookies.

Dropping the errors is concerning to me in case I do something wrong without even realizing.

Can someone help me understand what's going on?

-Who is trying to set cookies for server component clients? (I tried to debug but it only goes up to SupabaseAuthClient)
-Why is supabase server client example dropping exceptions ok for middleware refresh case?
GitHub
The React Framework. Contribute to vercel/next.js development by creating an account on GitHub.
Configure Supabase client to use Cookies
Was this page helpful?