Skip to main content

Introduction

Supabase is an open-source Firebase alternative. We currently use Supabase as our postgres database and authentication provider. To use Supabase in the application, you need to create a new client instance with the createClient method. It will automatically use the environment variables to connect to the Supabase API. Each client uses the cookies of the user to authenticate.

Use Supabase in Client Components

To use Supabase in client components, you need to create a new client instance with the createClient method of the client object. You can then use the client instance to interact with the Supabase API.

import { createClient } from '@/supabase/client';

const supabase = createClient();

Use Supabase in Server Components

To use Supabase in server components, you need to create a new client instance with the createClient method of the server object. You can then use the client instance to interact with the Supabase API.

import { createClient } from '@/supabase/server';

const supabase = createClient();

Use Supabase in Cloudflare Workers

To use Supabase in Cloudflare Workers, you need to create a new client instance with the createClient method of @supabase/supabase-js. You can then use the client instance to interact with the Supabase API. Please note that workers access the supabase instance with a service role, meaning they bypass all security rules.

import { createClient } from '@supabase/supabase-js';

const supabase = createClient();