Supabase Setup Guide for CRM Dashboard
Source: `docs/operations/SUPABASE_SETUP.md`View on GitHub
Supabase Setup Guide for CRM Dashboard
This guide will help you set up Supabase for your Property Management Companies CRM.
Step 1: Create a Supabase Account
- Go to https://supabase.com
- Click "Start your project" or "Sign In"
- Sign up with GitHub, Google, or email
- Verify your email if needed
Step 2: Create a New Project
- Click "New Project" on your Supabase dashboard
- Fill in the project details:
- Name:
pathfinder(or any name you prefer) - Database Password: Create a strong password (save this!)
- Region: Choose closest to Oregon (e.g., West US)
- Name:
- Click "Create new project"
- Wait 2-3 minutes for the project to initialize
Step 3: Create the Database Table
- In your Supabase project dashboard, click on "SQL Editor" in the left sidebar
- Click "New Query"
- Copy and paste the following SQL code:
-- Create the property_management_companies table
CREATE TABLE property_management_companies (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
company_name TEXT NOT NULL,
address TEXT,
city TEXT NOT NULL,
state TEXT DEFAULT 'Oregon',
zip_code TEXT,
contact_name TEXT NOT NULL,
contact_title TEXT,
phone TEXT,
email TEXT,
website TEXT,
units_managed INTEGER DEFAULT 0,
status TEXT DEFAULT 'Not Contacted',
priority TEXT DEFAULT 'Medium',
notes TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Enable Row Level Security (RLS)
ALTER TABLE property_management_companies ENABLE ROW LEVEL SECURITY;
-- Create a policy that allows all operations for now
-- (You can make this more restrictive later with authentication)
CREATE POLICY "Enable all access for property_management_companies"
ON property_management_companies
FOR ALL
USING (true)
WITH CHECK (true);
-- Create an index on city for faster searches
CREATE INDEX idx_pm_companies_city ON property_management_companies(city);
-- Create an index on status for filtering
CREATE INDEX idx_pm_companies_status ON property_management_companies(status);
- Click "Run" (or press Ctrl+Enter / Cmd+Enter)
- You should see "Success. No rows returned"
Step 4: Get Your API Credentials
- Click on the "Settings" icon (gear) in the left sidebar
- Click on "API" in the settings menu
- You'll see two important values:
- Project URL (looks like:
https://xxxxx.supabase.co) - anon public key (under "Project API keys")
- Project URL (looks like:
Step 5: Add Credentials to Your Project
- In your project root directory, create a file named
.env.local - Add the following content (replace with your actual values):
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
- Important: Make sure
.env.localis in your.gitignore(it already should be) - Save the file
Step 6: Restart Your Development Server
- Stop your development server (Ctrl+C in the terminal)
- Restart it:
npm run dev - Navigate to
http://localhost:3000/access-crm - Scroll down to the Property Management Companies section
Step 7: Test It Out!
- Click "+ Add Company" button
- Fill in a test company:
- Company Name:
Test Property Management - City:
Portland - Contact Person:
John Doe - Fill in other details as desired
- Company Name:
- Click "Add Company"
- The company should appear in the table!
Step 8: Share Access with Cole
To allow Cole to access the same data:
- Share your
.env.localfile contents with Cole securely (e.g., via encrypted message, password manager, or in person) - Cole should:
- Create a
.env.localfile in his project - Paste the same credentials
- Restart his development server
- Create a
Both of you will now see the same data in real-time!
Migrating Existing Data from localStorage
If you already have companies in localStorage, you can migrate them:
-
Manual Migration:
- Add each company through the form (they'll be saved to Supabase)
- Old localStorage data will remain as backup
-
Automatic: The app will:
- Try to load from Supabase first
- Fall back to localStorage if Supabase fails
- Keep localStorage as backup when new data is fetched
Viewing Your Data
You can view and manage data directly in Supabase:
- Go to your Supabase dashboard
- Click "Table Editor" in the left sidebar
- Select
property_management_companiestable - You can add, edit, or delete records here too!
Troubleshooting
"Error fetching companies"
- Check that your
.env.localfile exists and has correct values - Make sure you restarted the dev server after creating
.env.local - Verify the table was created successfully in Supabase
"Error adding company"
- Check the browser console (F12) for detailed error messages
- Verify your Supabase project is active (not paused)
- Check that RLS policies are set up correctly
Can't see the data Cole added
- Make sure both are using the same Supabase project credentials
- Refresh your browser page
- Check the Table Editor in Supabase to confirm data exists
Security Notes
- The current setup allows public access to the table (good for development)
- For production, consider:
- Adding user authentication
- Restricting RLS policies to authenticated users only
- Adding data validation rules
- Setting up backups
Next Steps
Once Supabase is working, you can:
- Add user authentication (Supabase Auth)
- Set up real-time subscriptions (see changes instantly)
- Add file uploads for company documents
- Create reports and analytics
- Deploy to production (Vercel + Supabase is free!)
Support
- Supabase Docs: https://supabase.com/docs
- Supabase Discord: https://discord.supabase.com
- Next.js Docs: https://nextjs.org/docs
Questions? Check the Supabase dashboard, or review the error messages in your browser console (F12).
Use links in each imported doc to open its source.