mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
* chore: prep expo example. * Modify Flutter user management example to use .env and initialize supabase * chore: add .env support to swift-user-management * chore: update supabase dependency for swift-user-management example * chore: minor expo updates. * chore: update auth nextjs example. --------- Co-authored-by: dshukertjr <dshukertjr@gmail.com> Co-authored-by: Guilherme Souza <grsouza@pm.me>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
|
import { cookies } from "next/headers";
|
|
|
|
export const createClient = () => {
|
|
const cookieStore = cookies();
|
|
|
|
return createServerClient(
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
{
|
|
cookies: {
|
|
get(name: string) {
|
|
return cookieStore.get(name)?.value;
|
|
},
|
|
set(name: string, value: string, options: CookieOptions) {
|
|
try {
|
|
cookieStore.set({ name, value, ...options });
|
|
} catch (error) {
|
|
// The `set` method was called from a Server Component.
|
|
// This can be ignored if you have middleware refreshing
|
|
// user sessions.
|
|
}
|
|
},
|
|
remove(name: string, options: CookieOptions) {
|
|
try {
|
|
cookieStore.set({ name, value: "", ...options });
|
|
} catch (error) {
|
|
// The `delete` method was called from a Server Component.
|
|
// This can be ignored if you have middleware refreshing
|
|
// user sessions.
|
|
}
|
|
},
|
|
},
|
|
},
|
|
);
|
|
};
|