itbm / chatbot-ui-supabase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chatbot UI Supabase Database Extension

This extension provides Supabase Database support (with RLS) for Chatbot UI.

Installation

Step 1

Add the extension with npm:

npm i @chatbot-ui/supabase@latest

Step 2

Run the Supabase Generation Script in the Supabase SQL editor.

This will do the following:

  • Create the tables required by Chatbot UI.
  • Create the authentication schema and tables required by NextAuth.js.
  • Enable Row Level Security for the tables required by Chatbot UI.
  • Apply the Row Level Security policies required by Chatbot UI.

Step 3

Expose the next_auth schema in the API settings by adding next_auth to the "Exposed schemas" list.

More information here.

Step 4

Update /chat.config.ts to use the new database.

import { ClientDatabase } from '@chatbot-ui/supabase';

export const ChatConfig = {
  ..., // Other config
  database: ClientDatabase,
  ... // Other config
};

};

Configuration

All the following env variables are required for the extension to work. These can be found here.

Environment Variable Default value Description
NEXT_PUBLIC_SUPABASE_URL '' The project URL.
NEXT_PUBLIC_SUPABASE_ANON_KEY '' The supabase project anon key.
SUPABASE_SERVICE_ROLE_KEY '' The supabase project service role key.
SUPABASE_JWT_SECRET '' Warning! Generating a new JWT Secret will invalidate all tokens above.

About

License:MIT License


Languages

Language:JavaScript 100.0%