Supabase Integration

Sync Doclayer document processing results to Supabase in real-time via webhooks and Edge Functions.

← Back to Integrations

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

1

Install the package

Add the Doclayer Supabase integration to your project:

npm install @doclayer/supabase
2

Apply 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 GitHub
3

Deploy the Edge Function

Deploy the webhook receiver Edge Function to handle Doclayer events:

supabase functions deploy doclayer-webhook --no-verify-jwt
4

Configure 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-webhook
5

Use realtime subscriptions

Subscribe to document processing updates in your React app using the provided hooks.

Database Tables

TableDescription
doclayer_documentsDocument processing status, results, and metadata
doclayer_extractionsIndividual extraction results linked to documents
doclayer_webhook_eventsLog of all received webhook events for debugging
doclayer_batchesBatch processing status and progress tracking
doclayer_billing_alertsBilling alerts (low credits, usage thresholds)
doclayer_usage_reportsUsage reports and cost tracking
doclayer_workflowsWorkflow execution tracking and results

Supported Webhook Events

document.processing.started

Document processing has begun

document.processing.completed

Document successfully processed

document.processing.failed

Document processing failed

batch.started

Batch processing started

batch.progress

Batch progress update

batch.completed

All documents in batch processed

billing.credits.low

Credits below threshold

workflow.completed

Workflow 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)