Setup Required
To activate real-time features, complete these steps in your Supabase dashboard:
- 1Add your Supabase credentials — set
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYin your.envfile. - 2Create the messages table — run this SQL in the Supabase SQL Editor:
CREATE TABLE messages ( id BIGSERIAL PRIMARY KEY, content TEXT NOT NULL, username TEXT NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW() ); -- Enable Row Level Security ALTER TABLE messages ENABLE ROW LEVEL SECURITY; -- Allow all reads CREATE POLICY "Allow reads" ON messages FOR SELECT USING (true); -- Allow all inserts CREATE POLICY "Allow inserts" ON messages FOR INSERT WITH CHECK (true); -- Allow all deletes CREATE POLICY "Allow deletes" ON messages FOR DELETE USING (true);
- 3Enable Replication — in Supabase go to Database → Replication and enable the
messagestable.
Real-Time Updates
Messages appear instantly via Supabase Realtime subscriptions — no polling needed.
PostgreSQL Backend
Data is persisted in a fully managed PostgreSQL database with Row Level Security.
Secure by Default
Row Level Security policies control data access at the database level.