An Open-Source AI Chatbot Template Built With Next.js and the AI SDK by Vercel.
Features · Model Providers · Deploy Your Own · Running locally
This template ships with OpenAI gpt-4o as the default. However, with the AI SDK, you can switch LLM providers to OpenAI, Anthropic, Cohere, and many more with just a few lines of code.
Watch our comprehensive onboarding video to quickly set up your development environment and understand the project structure: Watch Tutorial
Before you begin, ensure you have the following installed:
npm install -g pnpm)Install the Supabase CLI Choose the installation method for your operating system:
brew install supabase/tap/supabasescoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabasebrew install supabase/tap/supabasenpx supabase <command>Create a Supabase Project
# Create a new project
npx supabase projects create -i "ai-chatbot-supabase"
# Note: Save the project ID and database password shown after creationYour Organization ID can be found in the Supabase Dashboard URL after selecting an organization
Link Your Project
# Initialize Supabase configuration
npx supabase init
# Link to your remote project
npx supabase link --project-ref your-project-idYou'll need your project ID and database password from step 2.
Configure Environment Variables
Create a .env.local file with the following variables:
NEXT_PUBLIC_SUPABASE_URL=<api-url>
NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon-key>Find these values in your Supabase project dashboard under Project Settings > API
Initialize Database Schema
# Apply all migrations
supabase db push
# Verify the schema
supabase db reset --dry-runClone and Install
git clone https://github.com/your-username/ai-chatbot-supabase.git
cd ai-chatbot-supabase
pnpm installStart Development Server
pnpm devThe application will be available at http://localhost:3000
Development Commands
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run ESLint
pnpm type-check # Run TypeScript checksCommon issues and solutions:
Supabase Connection Issues
Build Errors
.next folder: rm -rf .nextpnpm clean-installFor more help, open an issue.
Fork the Repository
https://github.com/your-username/ai-chatbot-supabaseConfigure Vercel Project
Set Environment Variables In your Vercel project settings, add the following environment variables:
# Required
NEXT_PUBLIC_SUPABASE_URL= # From Supabase project settings
NEXT_PUBLIC_SUPABASE_ANON_KEY= # From Supabase project settings
OPENAI_API_KEY= # Your OpenAI API keyConfigure Build Settings In your Vercel project settings:
pnpm build.nextpnpm installDeploy