SupabaseS
Supabase•12mo ago
Kobaru

Using Supabase in NextJS Server Side

Hi 👋
I have a question concerning how to use Supabase in NextJS env, especially on the server side.
Right now, every time I hit one of my API End Point I end up creating a new supabase client using
import { createClient } from "@supabase/supabase-js"

Is this considered ok or a bad practice ?
I know in front it is advised to create only one client and serve it among every components, but is it the same for backend ?
If I should use only one I'm not sure how to "share" this unique client with every end point route.js files
I feel like doing a Promise to init my createClient every time I hit a end point might not be right but I'm not sure.
Was this page helpful?