This is a Supabase edge function which acts as a backend for Replicache. It is based on a combination of the various examples in the Replicache repositories.
- Implementation of the Replicache key:value store using Supabase's Postgres database
- Endpoints for Replicache
push
,pull
,create-space
andspace-exists
functions - Auth tokens are forwarded to the DB for use with Row Level Security if required
The easiest way to get started is to clone this repo into a local supabase/cli project.
The index.ts
file imports a mutators
object from ../_shared/mutators.ts
. Create this file and copy in your mutators from your Replicache client. Recommended directory structure for Supabase functions is found in the supabase edge function docs.
From your Supabase project root, run:
git clone https://github.com/onsetsoftware/replicache-supabase-edge-function.git supabase/functions/replicache
supabase start
# !! make sure your mutators file has been added !!
supabase functions serve replicache
The function exposes 4 endpoints:
POST /push?spaceID={spaceID}
POST /pull?spaceID={spaceID}
POST /create-space?spaceID={spaceID}
POST /space-exists?spaceID={spaceID}
For example, in local development a typical URL would look like http://localhost:54321/functions/v1/push?spaceID=123
.