{"id":31136018,"url":"https://github.com/letstri/tanstack-db-pglite","last_synced_at":"2025-09-20T11:55:57.035Z","repository":{"id":314811115,"uuid":"1056809507","full_name":"letstri/tanstack-db-pglite","owner":"letstri","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-14T22:23:22.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-15T00:22:21.049Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/letstri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-14T21:03:24.000Z","updated_at":"2025-09-14T22:23:25.000Z","dependencies_parsed_at":"2025-09-15T00:22:38.964Z","dependency_job_id":"bbcd4df4-566a-4786-b2c3-319abf296a10","html_url":"https://github.com/letstri/tanstack-db-pglite","commit_stats":null,"previous_names":["letstri/tanstack-db-pglite"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/letstri/tanstack-db-pglite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftanstack-db-pglite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftanstack-db-pglite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftanstack-db-pglite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftanstack-db-pglite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letstri","download_url":"https://codeload.github.com/letstri/tanstack-db-pglite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letstri%2Ftanstack-db-pglite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275732385,"owners_count":25518095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-18T07:54:46.014Z","updated_at":"2025-09-18T07:54:48.316Z","avatar_url":"https://github.com/letstri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tanstack-db-pglite\n\nA seamless integration between [TanStack DB](https://tanstack.com/db) and [PGLite](https://github.com/electric-sql/pglite) with [Drizzle ORM](https://orm.drizzle.team/) for browser-based database management.\n\n## Installation\n\n```bash\nnpm install tanstack-db-pglite @tanstack/db drizzle-orm @electric-sql/pglite\n```\n\n\u003e **Note:** `@tanstack/db` and `drizzle-orm` are peer dependencies and must be installed separately.\n\n## Quick Start\n\n```typescript\nimport { PGLite } from '@electric-sql/pglite'\nimport { createCollection } from '@tanstack/react-db'\nimport { drizzle } from 'drizzle-orm/pglite'\nimport { drizzleCollectionOptions } from 'tanstack-db-pglite'\nimport { chats } from '~/drizzle'\n\nconst pglite = new PGLite()\nconst db = drizzle(pglite)\n\nexport const chatsCollection = createCollection(drizzleCollectionOptions({\n  db,\n  table: chats,\n  primaryColumn: chats.id,\n  prepare: async () =\u003e {\n    // Prepare your database before starting the collection (e.g., run migrations)\n    await waitForMigrations()\n  },\n  sync: async ({ collection, write }) =\u003e {\n    // Send some data to your backend to sync and receive the response\n    const sync = await syncWithCloud(\n      collection.toArray.map(c =\u003e ({\n        id: c.id,\n        updatedAt: c.updatedAt\n      }))\n    )\n\n    sync.forEach((item) =\u003e {\n      if (item.type === 'delete') {\n        write({ type: 'delete', value: collection.get(item.value)! })\n      }\n      else {\n        write(item)\n      }\n    })\n  },\n  onInsert: async (params) =\u003e {\n    await saveInCloud(params)\n  },\n  onUpdate: async (params) =\u003e {\n    await updateInCloud(params)\n  },\n  onDelete: async (params) =\u003e {\n    await deleteInCloud(params)\n  },\n}))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletstri%2Ftanstack-db-pglite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletstri%2Ftanstack-db-pglite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletstri%2Ftanstack-db-pglite/lists"}