This guide will help you set up the admin dashboard for your portfolio with Supabase authentication and database.
- Go to your Supabase project dashboard
- Navigate to SQL Editor
- Copy and paste the contents of
lib/supabase/schema.sql - Click Run to create all tables and policies
- In Supabase dashboard, go to Authentication > Users
- Click Add User > Create new user
- Enter your email and password
- After creating the user, copy the user's UUID
- Go to SQL Editor and run:
INSERT INTO admin_users (id, email, role)
VALUES ('YOUR_USER_UUID_HERE', 'your-email@example.com', 'admin');Replace YOUR_USER_UUID_HERE with the actual UUID from step 4.
The schema file already includes RLS policies. Verify they're enabled:
- Go to Database > Tables
- For each table, click the table name
- Ensure "RLS enabled" is checked
If you want to upload images:
- Go to Storage
- Create a new bucket called
project-images - Set up policies:
- Public read access
- Authenticated admin write access
Your .env file should already be configured with:
NEXT_PUBLIC_SUPABASE_URL=https://yrdayxeixupvhkilrdcd.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key- Start your development server:
pnpm dev - Navigate to:
http://localhost:3000/admin/login - Enter your admin credentials (email and password you created in Step 2)
After logging in, you'll have access to:
- Dashboard - Overview of all content
- Projects - Manage portfolio projects
- Testimonials - Manage client testimonials
- Education - Manage education history
- Experience - Manage work experience
- Skills - Manage skills and proficiencies
I've created the following pages:
- ✅ Projects management
- ✅ Testimonials management
- ⏳ Education management (to be created)
- ⏳ Experience management (to be created)
- ⏳ Skills management (to be created)
Follow the same pattern as Projects and Testimonials:
- Create
app/admin/dashboard/[section]/page.tsx(list page) - Create
app/admin/dashboard/[section]/[Section]Dialog.tsx(edit/create dialog)
The structure is consistent across all sections.
To migrate your existing hardcoded projects to the database:
- Log into the admin dashboard
- Manually add each project, OR
- Use the SQL Editor in Supabase to bulk insert:
INSERT INTO projects (title, description, tech_stack, link, icon_name, type, category, featured, pinned)
VALUES
('Al Quran Institute', 'Educational platform for Quran studies...', 'Next.js, Tailwind, Express, API', 'https://alquraninstitute.net/', 'BookOpen', 'live', 'Web', true, true),
-- Add more projects...
;After setting up the database, update your frontend components to fetch from Supabase instead of using hardcoded data:
"use client"
import { useEffect, useState } from "react"
import { supabase } from "@/lib/supabase/client"
export default function Projects() {
const [projects, setProjects] = useState([])
useEffect(() => {
const fetchProjects = async () => {
const { data } = await supabase
.from("projects")
.select("*")
.order("order_index", { ascending: true })
setProjects(data || [])
}
fetchProjects()
}, [])
// Rest of your component...
}⚠️ Never commit.envor.env.localto git (already in .gitignore)⚠️ The service role key has full database access - keep it secret⚠️ Only use service role key in server-side code or admin operations- ✅ RLS policies protect your data from unauthorized access
- ✅ Admin verification happens in middleware
When deploying to Vercel:
-
Add environment variables in Vercel dashboard:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY
-
Deploy:
vercel --prod
- Verify user exists in Authentication > Users
- Verify user exists in admin_users table
- Check browser console for errors
- Ensure admin_users table has your user ID
- Verify RLS policies are enabled
- Check policy conditions
- Check Supabase logs in Dashboard > Logs
- Verify data exists in tables
- Check browser console for errors
- ✅ Run the SQL schema to create tables
- ✅ Create your admin user
- ✅ Test login at
/admin/login - ⏳ Create remaining admin pages (education, experience, skills)
- ⏳ Migrate existing data
- ⏳ Update frontend components to fetch from Supabase
- ⏳ Deploy to production
app/
├── admin/
│ ├── layout.tsx
│ ├── login/
│ │ └── page.tsx
│ └── dashboard/
│ ├── layout.tsx
│ ├── page.tsx
│ ├── projects/
│ │ ├── page.tsx
│ │ └── ProjectDialog.tsx
│ ├── testimonials/
│ │ ├── page.tsx
│ │ └── TestimonialDialog.tsx
│ ├── education/ (to be created)
│ ├── experience/ (to be created)
│ └── skills/ (to be created)
lib/
├── supabase/
│ ├── client.ts
│ ├── server.ts
│ ├── database.types.ts
│ └── schema.sql
middleware.ts
.env.local.example