codeAI
Docs

supabase integration

Supabase Integration with CodeAI

This document outlines how to integrate Supabase with your projects using CodeAI.

What is Supabase?

Supabase is an open-source Firebase alternative that provides a PostgreSQL database, authentication, instant APIs, real-time subscriptions, and storage.

Integrating Supabase

CodeAI can help you with:

  • Database Setup: Generating SQL schemas for your PostgreSQL database.
  • Client Libraries: Providing code examples for using Supabase client libraries (e.g., supabase-js) in your frontend or backend.
  • Authentication: Setting up user authentication with Supabase Auth.
  • Edge Functions: Writing and deploying serverless functions with Supabase Edge Functions.
  • Storage: Managing file uploads and downloads with Supabase Storage.
  • Realtime: Implementing real-time features using Supabase Realtime.

Common Tasks

  • Connecting to Supabase:

    import { createClient } from '@supabase/supabase-js';
    
    const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
    const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
    
    export const supabase = createClient(supabaseUrl, supabaseAnonKey);
    
  • Fetching Data:

    const { data, error } = await supabase.from('your_table').select('*');
    
  • Inserting Data:

    const { data, error } = await supabase.from('your_table').insert([{ column_name: 'value' }]);
    
  • Using Drizzle ORM with Supabase: CodeAI can generate Drizzle schemas and queries for your Supabase database.