pgreflex (v0.0.19) is a reactive Postgres library that integrates with tRPC and Drizzle ORM to automatically reflect database changes in the frontend. It uses PostgreSQL logical replication via the pg_output plugin to listen to WAL changes and sends invalidations to tRPC procedures. Inspired by Convex, it provides granular, automatic invalidation without manual cache management. Requires REPLICA IDENTITY FULL for correct updates. Currently in early development with rapid releases; performance overhead is sub-1ms in same datacenter. Differentiators: works with any Postgres + tRPC + Drizzle stack, and aims for Neon DB compatibility.
npm install pgreflexNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a reactive tRPC server that automatically invalidates queries when database changes occur via Postgres logical replication.
ALTER TABLE <table> REPLICA IDENTITY FULL;
Use named exports exclusively.
Set wal_level=logical in postgresql.conf and restart Postgres.
Ensure either the Postgres user has replication privileges or create resources manually.
Use the same db instance for all queries in the middleware.
Run: ALTER TABLE "users" REPLICA IDENTITY FULL;
Set wal_level = logical in postgresql.conf and restart the server.
Grant REPLICATION privilege: ALTER USER your_user WITH REPLICATION; or create slot manually.