- ✅ Installed
@supabase/supabase-js - ✅ Created Supabase client (
/lib/supabase.ts) - ✅ Updated ContactForm to submit to Supabase
- ✅ Added loading states and error handling
- ✅ Added success/error messages
Create a file named .env.local in the root directory:
cd /Users/hamzashahid/structurewebsite
touch .env.localAdd these contents to .env.local:
NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-keyGo to your Supabase project dashboard: https://supabase.com/dashboard/project/YOUR_PROJECT_ID
Navigate to: SQL Editor → New Query
Run this SQL:
-- Create contact_submissions table
CREATE TABLE contact_submissions (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
phone TEXT NOT NULL,
company TEXT NOT NULL,
message TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Add index for faster queries
CREATE INDEX idx_contact_submissions_created_at
ON contact_submissions(created_at DESC);
-- Add index for email lookups
CREATE INDEX idx_contact_submissions_email
ON contact_submissions(email);
-- Enable Row Level Security (RLS)
ALTER TABLE contact_submissions ENABLE ROW LEVEL SECURITY;
-- Create policy to allow inserts from anyone
CREATE POLICY "Allow public inserts"
ON contact_submissions
FOR INSERT
TO public
WITH CHECK (true);
-- Create policy to allow reads for authenticated users only
CREATE POLICY "Allow authenticated reads"
ON contact_submissions
FOR SELECT
TO authenticated
USING (true);# Kill current server
pkill -f "next dev"
# Start fresh (will pick up .env.local)
npm run dev- User fills out contact form
- Data is validated
- Submitted to Supabase
contact_submissionstable - Success message shown
- Email also sent as backup
- Name
- Phone
- Company
- Message
- Timestamp
Go to Supabase Dashboard → Table Editor → contact_submissions
You can:
- View all submissions
- Export to CSV
- Set up email notifications
- Create automated workflows
✅ Row Level Security (RLS) enabled ✅ Public can insert only (submit forms) ✅ Only you can read (view submissions) ✅ Anon key used (safe for client-side) ✅ Service role key NOT exposed (kept secret)
Run this to create .env.local:
cat > /Users/hamzashahid/structurewebsite/.env.local << 'EOF'
NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
EOFOnce you:
- Create
.env.localwith credentials - Run the SQL in Supabase to create table
- Restart dev server
All form submissions will save to your Supabase database! 🎉
The form ALSO sends an email to sales@structurelogistics.com as a backup, so you get submissions both:
- In Supabase database
- In your email inbox
Double coverage! ✨