Overview
AniDojo uses Supabase as its backend platform, providing authentication, PostgreSQL database, and file storage. This guide walks you through creating and configuring your Supabase project.Prerequisites
- A Supabase account (Sign up for free)
- Node.js 18+ installed
- Basic familiarity with SQL and environment variables
Create Your Supabase Project
Sign in to Supabase
Navigate to supabase.com and sign in to your account.
Create a new project
Click New Project and fill in the details:
- Name:
anidojo(or your preferred name) - Database Password: Generate a strong password (save this!)
- Region: Choose the region closest to your users
- Pricing Plan: Free tier works great for development
Get Your API Credentials
Once your project is ready, you’ll need to retrieve your API credentials.Configure Environment Variables
Add your Supabase credentials to your Next.js application.The
NEXT_PUBLIC_ prefix makes these variables available in the browser. This is safe for the anon key, which is designed for client-side use.Verify Your Connection
Test that your application can connect to Supabase:Supabase Client Architecture
AniDojo uses different Supabase clients depending on the context:Client-Side Browser Client
Client-Side Browser Client
Used in React components and client-side code:Located in:
src/lib/supabase/client.tsServer-Side Server Client
Server-Side Server Client
Used in Server Components, API routes, and Server Actions:Located in:
src/lib/supabase/server.tsMiddleware Client
Middleware Client
Used in Next.js middleware for session management:Located in:
src/lib/supabase/middleware.tsNext Steps
Now that your Supabase project is set up, you can:Database Schema
Set up your database tables and migrations
Authentication
Configure user authentication and providers
Storage Buckets
Create storage buckets for avatars and images
API Integration
Connect to the Jikan anime API
Troubleshooting
”Invalid API key” error
- Verify your
.env.localfile has the correct values - Make sure you copied the anon key, not the service_role key
- Restart your development server after changing environment variables
Connection timeout
- Check your internet connection
- Verify your Supabase project is active (not paused)
- Confirm the Project URL is correct
CORS errors
- Ensure you’re using the client-side client (
@/lib/supabase/client) in browser code - Use the server-side client (
@/lib/supabase/server) in API routes and Server Components