Prerequisites
- A Supabase account (sign up at supabase.com)
- Basic knowledge of SQL and environment variables
Create a Supabase Project
Create New Project
- Log in to your Supabase dashboard
- Click “New Project”
- Fill in your project details:
- Project name:
clipsync(or your preferred name) - Database password: Choose a strong password
- Region: Select the closest region to your users
- Project name:
- Wait for the project to be provisioned (usually 1-2 minutes)
Database Tables Setup
ClipSync requires three database tables:sessions, clipboard, and counter. Create them using the SQL Editor in your Supabase dashboard.
Sessions Table
Stores active clipboard sync sessions with unique codes.src/service/doc.service.js:10
Session codes are 5-character alphanumeric strings (e.g.,
AB12C) that allow users to join the same sync session across multiple devices.Clipboard Table
Stores clipboard content entries for each session.src/App.jsx:34, src/App.jsx:179
Field Descriptions:
session_code: Links clipboard entry to a sessioncontent: Text content (max 15,000 characters)fileUrl: Public URL of uploaded file from storagefile: JSON metadata about the uploaded file (path, type, etc.)sensitive: Boolean flag to hide sensitive content in UI
Counter Table
Tracks application usage statistics.src/App.jsx:270
Storage Bucket Setup
ClipSync uses Supabase Storage to handle file and image uploads.Create Storage Bucket
- Navigate to Storage in your Supabase dashboard
- Click “Create Bucket”
- Bucket name:
clipboard - Set the bucket to Public (required for direct file access)
src/App.jsx:151, src/App.jsx:596
Files are uploaded with a 3-character random prefix to prevent naming collisions (see
src/App.jsx:130-134). Images are automatically compressed before upload using browser-image-compression (see src/compressedFileUpload.jsx:3-16).File Upload Limits
- Maximum file size: 10MB (enforced at
src/App.jsx:125) - Supported file types: Documents (Word, Excel, PowerPoint), PDFs, text files, and images
- Images are compressed to max 0.2MB with 1920px max dimension before upload
Environment Variables Configuration
Create a.env file in your client project root with your Supabase credentials.
.env
src/config/supabase.js:1-2
The application initializes the Supabase client in src/config/supabase.js:5:
Real-time Subscriptions Setup
ClipSync uses Supabase Real-time to sync clipboard changes across devices instantly.Enable Real-time for Tables
Enable Real-time Replication
- Go to Database > Replication in Supabase dashboard
- Enable replication for the
clipboardtable - Select all events:
INSERT,UPDATE,DELETE
How Real-time Works
- INSERT events: When a user sends clipboard content, all devices in the session instantly receive it
- DELETE events: When content is deleted, it’s removed from all connected devices
- Session isolation: Each subscription filters by
session_codeto ensure users only see their session’s data
Database Security
Row Level Security (RLS)
While ClipSync currently uses the anon key for simplicity, consider implementing RLS policies for production:Verification
Test your Supabase setup:Create a Session
Click “Send to Clipboard” without joining a session - a new 5-character code should be generated
Test Real-time Sync
- Copy your session code
- Open ClipSync in another browser tab or device
- Join using the same session code
- Send clipboard content from one device
- Verify it appears instantly on the other device
Troubleshooting
Connection Issues
- Verify your
VITE_SUPABASE_URLandVITE_SUPABASE_ANON_KEYare correct - Check that environment variables are loaded (restart dev server after changes)
- Ensure your Supabase project is active and not paused
Real-time Not Working
- Confirm Real-time is enabled for the
clipboardtable - Check browser console for WebSocket connection errors
- Verify the user is online (ClipSync shows an offline indicator)
File Upload Failures
- Check file size is under 10MB
- Verify the
clipboardstorage bucket exists and is public - Ensure storage policies allow public uploads
Next Steps
PWA Installation
Install ClipSync as a Progressive Web App
Multi-Device Sync
Learn how to sync across devices