Skip to content
Contents

Full-stack sync, with Zero

Coming soon. This is not available yet. The page is a sketch, here for review.

Rindle directly supports the Zero sync framework. Your schemas, queries, mutators and useQuery components stay the same. The only thing that changes is performance – Rindle is much faster.

Architecture

With Zero, the browser talks to zero-cache, which calls your server and follows Postgres. With Rindle, the browser talks to your server, and your server talks to Rindle, the same shape as Architecture. Postgres is optional.

A Zero app on Rindle The Zero client opens a stream through your API server, which connects to the Rindle server; Rindle's stream flows back through your API server to the client. The client's /query calls become rindle.addQuery on the Rindle server. Its /mutate calls go to your API server, which writes either to Rindle or, optionally, to Postgres. When Postgres is used, Rindle follows its changes. ZERO CLIENT @rindle/zero useQuery, z.mutate API SERVER your queries and mutators RINDLE SERVER /api/rindle-connect stream (proxied) /query /mutate /connect stream /add-query write /exec SQL POSTGRES optional changes
Mutators write to Rindle, or to Postgres if you keep it. With Postgres, Rindle follows its changes.

Client

Change one import. cacheURL points at your server instead of zero-cache.

-import { Zero } from "@rocicorp/zero";
+import { Zero } from "@rindle/zero";

 const zero = new Zero({ schema, mutators, cacheURL: "/api/zero", auth, userID });

React components keep useQuery from @rindle/zero/react.

Server

Your /query and /mutate endpoints keep their auth, their routes, and the bodies of every query and mutator. Only the glue changes:

-import { handleMutateRequest, handleQueryRequest } from "@rocicorp/zero/server";
+import { createZeroApiServer } from "@rindle/zero/server";
+
+const api = createZeroApiServer({ schema, queries, mutators }); // reads RINDLE_URL

 export async function POST(request: Request) {
   const user = await getUser(request); // your auth
-  return handleQueryRequest(/* … */);
+  return api.handleQuery(request, { user });
 }

Your data

  • Rindle is the database. Run rindle up and write migrations in SQL. Mutators write to Rindle.
  • Postgres stays the database. Mutators keep writing to Postgres through your existing connection (drizzle, kysely, prisma, postgres.js). Rindle follows it with logical replication.