This tutorial guides you through connecting Supabase to n8n, enabling data flows between your Supabase database and n8n workflows. It's for technical users familiar with n8n basics who want precise steps to integrate Supabase's PostgreSQL backend, REST API, and real-time features without common setup errors.
Why this matters
Integrating Supabase with n8n streamlines automations by using Supabase's scalable PostgreSQL database and real-time subscriptions, but misconfigurations like using the wrong API key or ignoring Row Level Security (RLS) can lead to failed queries or security breaches. This connection avoids the hassle of manual data syncing, allowing you to trigger workflows on database events or push updates via edge functions, saving hours on repetitive tasks in your automation stack.
Step-by-step
- Open your n8n instance and create a new workflow. In the workflow canvas, click the '+' button to add a trigger node; for this integration, select the
Supabase Triggernode if you're starting with real-time events, or use aSchedule Triggerfor periodic polling. If the Supabase node isn't available, install it via the Community Nodes section in n8n settings by searching for 'n8n-nodes-supabase' and restarting n8n. - Obtain your Supabase credentials. Log in to your Supabase dashboard, navigate to Settings > API, and copy the Project URL (e.g.,
https://yourproject.supabase.co). For authentication, decide between the anon key for public access or the service role key for full admin privileges—use the service role key (eyJ...service_role) only in secure n8n environments to bypass RLS. - Add a Supabase credential in n8n. In the node settings, click 'Create New Credential', select Supabase, and paste the Project URL into the Host field. Enter your chosen API key in the API Key field, name the credential (e.g., 'Supabase Prod'), and save it. Test the connection by clicking 'Test Credential'—expect a success message if valid.
- Configure the Supabase node for your operation. For a basic insert, drag in the
Supabasenode (not the Postgres node, unless you need raw SQL). Set Resource to 'Table', Operation to 'Create', and select your target table (e.g., 'users'). In the Columns field, map input data like{ "email": "{{ $json.email }}", "name": "{{ $json.name }}" }—ensure your input comes from a previous node like a webhook. - Handle RLS considerations. If RLS is enabled on your table (check in Supabase SQL Editor with
SELECT * FROM auth.rls_policies;), the anon key will filter rows based on policies; switch to service role key for unrestricted access, but never expose it in client-side code. Test by running the workflow and verifying data in Supabase's Table Editor. - Set up real-time triggers. In the
Supabase Triggernode, choose Event as 'Insert' or 'Update', specify the Schema (usually 'public') and Table name. Authenticate with your credential—n8n will subscribe via Supabase's Realtime server. Expect the node to output JSON payloads on events, like{ "type": "INSERT", "record": { "id": 1, "email": "user@example.com" } }. - Integrate with edge functions if needed. For custom logic, create an edge function in Supabase (via Dashboard > Edge Functions), then use n8n's
HTTP Requestnode to invoke it: set Method to POST, URL tohttps://yourproject.supabase.co/functions/v1/your-function, and headers withAuthorization: Bearer YOUR_ANON_KEYandContent-Type: application/json. Pass body data from prior nodes. - Compare REST vs Postgres node. Stick to the
Supabasenode for REST API calls (faster for simple CRUD); use thePostgresnode for complex queries, connecting via Supabase's direct Postgres URL (from Settings > Database) and a dedicated database credential. In Postgres node, set Host to your DB URL without protocol, Username to 'postgres', Password to your DB password, and Database to 'postgres'—avoid this for real-time needs. - Save and activate the workflow. Click 'Save' in the top bar, then toggle 'Active' on. Monitor executions in the Executions tab; if errors occur (e.g., 401 Unauthorized), double-check keys and RLS policies.
Worked example
This example automates user onboarding: when a new user signs up via Supabase Auth, a real-time trigger in n8n detects the insert into the 'auth.users' table (or a mirrored 'users' table), then creates a welcome email via Send Email node and adds a profile record in a custom 'profiles' table.
Start with a Supabase Trigger node set to Event 'INSERT' on Schema 'public' and Table 'users', using your service role credential to bypass RLS. It outputs the new user data, like { "id": "uuid-here", "email": "newuser@example.com" }. Connect to a Set node to prepare email variables, mapping email: {{ $json.email }} and a static subject 'Welcome to Our Platform'.
Next, add a Send Email node (IMAP or SMTP credential required) with To set to {{ $node["Set"].json["email"] }} and body including the user's name if available. Finally, chain a Supabase node with Operation 'Create' on 'profiles' table, inserting { "user_id": "{{ $json.id }}", "status": "active" }. End-to-end, a Supabase signup instantly triggers the email and profile setup, visible in n8n's execution log and Supabase dashboard.
Common pitfalls
- RLS blocking inserts/updates: Symptom: Queries succeed in Supabase dashboard but fail in n8n with permission errors. Fix: Enable RLS policies to allow the operation (e.g., via SQL:
ALTER POLICY "Users can insert" ON users FOR INSERT WITH CHECK (auth.uid() = id);) or use service role key in your credential for admin access, but restrict this to server-side n8n instances. - Wrong key exposure: Symptom: Workflows work locally but break in production due to key revocation or leaks. Fix: Use environment variables for keys in n8n (e.g.,
process.env.SUPABASE_KEYin custom nodes) and differentiate anon for read-only triggers versus service role for writes; audit logs in Supabase to detect misuse. - Real-time subscriptions not firing: Symptom: Trigger node shows connected but no outputs on database changes. Fix: Ensure Realtime is enabled in Supabase Dashboard > Settings > API, and verify the table broadcasts changes (add
ALTER PUBLICATION supabase_realtime ADD TABLE your_table;in SQL Editor); test with a manual insert and check n8n logs for WebSocket errors. - REST vs Postgres confusion: Symptom: Complex joins fail in Supabase node but work in raw SQL tools. Fix: Switch to
Postgresnode for advanced queries, providing the full connection string (e.g.,postgresql://postgres:[PASSWORD]@db.yourproject.supabase.co:5432/postgres); use REST for simple ops to avoid direct DB exposure risks. - Edge function auth failures: Symptom: HTTP 401 errors when calling functions from n8n. Fix: Include the anon key in Authorization header as
Bearer [ANON_KEY], and ensure the function's Supabase client initialises with the same key; test invocation separately via curl before integrating.
Related workflows in the catalog
Explore the n8n workflow catalog for ready-to-import templates like 'Supabase to Slack Notifications', which syncs database changes to team chats, or 'User Sync from Supabase to Google Sheets' for automated reporting. With over 14,000+ importable workflows, search for 'Supabase' to find variants including real-time CRM updates or edge function-driven data pipelines. These can be customised directly in your n8n editor to fit your automation needs.