supabase-edge-functions

Deploy and manage Supabase Edge Functions. Use for invoking serverless functions, deploying new functions, and managing function deployments.

By nice-wolf-studio · 351 installs

npx skills add nice-wolf-studio/claude-code-supabase-skills --skill supabase-edge-functions

Source repository · Upstream listing

Supabase Edge Functions Overview This skill provides operations for working with Supabase Edge Functions serverless TypeScript/JavaScript functions that run on Deno Deploy. Use for invoking functions, deploying code, and managing function lifecycles. Prerequisites Required environment variables: Required tools: Supabase CLI ( supabase command) Deno (for local development) Install Supabase CLI: Helper script: This skill uses the shared Supabase API helper for invoking functions: Invoke Edge Functions Basic Invocation Invoke a function with POST: Invoke with GET: Invoke with Headers Pass custom headers: Invoke with Authentication Invoke function as authenticated user: Function Management (CLI) Initialize Function Create a new edge function: Function Template Basic function structure: Function with authentication: Deploy Function Deploy a function to Supabase: Set Environment Variables Set secrets for edge functions: Local Development Run functions locally: Delete Function Remove a deployed function: Common Patterns Invoke and Process Response Batch Function Invocations Function with Retry Logic Deploy Function Script Monitor Function Logs Advanced Patterns Function with Database Access Function with External API Call Scheduled Function (Cron) Set up cron job in Supabase Dashboard: Testing Functions Test Locally Integration Test Script Error Handling Function errors return HTTP status codes: Status Meaning 200 Success 400 Bad request (invalid input) 401 Unauthorized (invalid/missing auth) 403 Forbidden (insufficient permissions) 500 Internal server error (function crashed) 504 Gateway timeout (function took too long) Timeout limit: Edge functions have a 2 second CPU time limit and 150 second wall clock timeout. Security Best Practices 1. Validate input : Always validate and sanitize request data 2. Use service role key carefully : Only in admin functions, never expose to clients 3. Implement authentication : Check user tokens for protected functions 4. Rate limiting : Implement rate limiting for public functions 5. Environment variables : Store secrets in Supabase secrets, not in code 6. CORS : Configure CORS headers appropriately 7. Error messages : Don't leak sensitive information in error responses Performance Tips 1. Cold starts : Functions may have cold starts (100 200ms delay) 2. Keep functions small : Faster cold starts and easier debugging 3. Cache external data : Use in memory caching for repeated API calls 4. Parallel execution : Use Promise.all() for concurrent operations 5. Stream large responses : Use streaming for large data transfers API Documentation Supabase Edge Functions: https://supabase.com/docs/guides/functions Deno Deploy: https://deno.com/deploy/docs