Supabase Integration
Sync Doclayer document processing results to Supabase in real-time via webhooks and Edge Functions.
Supabase Integration
Real-time document sync via webhooks
Sync Doclayer document processing results directly to your Supabase database. Get real-time updates via Postgres Realtime and build reactive UIs with the included React hooks.
Features
Real-time Updates
Get instant document status updates via Supabase Realtime subscriptions.
Automatic Sync
Document results synced to your database as webhooks arrive.
React Hooks
Pre-built hooks for document status, extractions, and batch progress.
Event Replay
All webhook events logged for debugging and replay capability.
Setup Guide
Install the package
Add the Doclayer Supabase integration to your project:
npm install @doclayer/supabaseApply database migrations
Run the migrations to create the Doclayer tables in your Supabase database. Copy the migration files from the package to your supabase/migrations folder.
View migrations on GitHubDeploy the Edge Function
Deploy the webhook receiver Edge Function to handle Doclayer events:
supabase functions deploy doclayer-webhook --no-verify-jwtConfigure webhook in Doclayer
Add your Supabase Edge Function URL as a webhook endpoint in your Doclayer dashboard:
https://your-project.supabase.co/functions/v1/doclayer-webhookUse realtime subscriptions
Subscribe to document processing updates in your React app using the provided hooks.
Database Tables
| Table | Description |
|---|---|
| doclayer_documents | Document processing status, results, and metadata |
| doclayer_extractions | Individual extraction results linked to documents |
| doclayer_webhook_events | Log of all received webhook events for debugging |
| doclayer_batches | Batch processing status and progress tracking |
| doclayer_billing_alerts | Billing alerts (low credits, usage thresholds) |
| doclayer_usage_reports | Usage reports and cost tracking |
| doclayer_workflows | Workflow execution tracking and results |
Supported Webhook Events
document.processing.startedDocument processing has begun
document.processing.completedDocument successfully processed
document.processing.failedDocument processing failed
batch.startedBatch processing started
batch.progressBatch progress update
batch.completedAll documents in batch processed
billing.credits.lowCredits below threshold
workflow.completedWorkflow execution finished
React Hook Example
Subscribe to document status updates in real-time:
import { useDoclayerDocument } from '@doclayer/supabase';
function DocumentStatus({ jobId }) {
const { document, loading, error } = useDoclayerDocument(jobId);
if (loading) return <Spinner />;
if (error) return <Error message={error} />;
return (
<div>
<p>Status: {document.status}</p>
<p>Insights: {document.insights_count}</p>
{document.status === 'completed' && (
<p>Confidence: {document.confidence_metrics?.overall}</p>
)}
</div>
);
}Prerequisites
- Supabase project (local or hosted)
- Doclayer account with webhook access
- Supabase CLI installed (for Edge Function deployment)