A TypeScript-first adapter integrating Better Auth with PocketBase as the authentication backend. Current version 1.0.16 (2024+), actively maintained. It translates Better Auth's CRUD operations into PocketBase collection queries, supporting sessions, accounts, verifications, and batch operations. Key differentiators: PocketBase-native admin API usage, full type safety, customizable table names (singular/plural), and debug logging. Requires PocketBase >=0.20.0 and better-auth >=1.2.6. Tested with 17+ unit tests. No known security incidents.
npm install pocketbase-better-authVerified import paths — ran on the pinned version, not inferred.
Shows minimal setup: create PocketBase client, authenticate as admin, and pass adapter with options to betterAuth.
Upgrade PocketBase to 0.20.0 or later using `npm install pocketbase@^0.20.0`.
Store PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD in .env file and reference with process.env. Also ensure the PocketBase URL is not exposed to untrusted networks.
In adapter config, add `usePlural: true`. Alternatively, import the provided schema (singular) from 'schema/pocketbase.collections.json'.
When importing schema, ensure the 'user' collection is created as a regular collection, not as an Auth collection. See the provided schema file.
Avoid using batch operations with large numbers of records in a single call. Consider batching manually with smaller chunks if needed.
Run `npm install pocketbase-better-auth better-auth pocketbase` in the project root. Ensure node_modules is not ignored.
Verify PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD are correct. Add `console.log(pb.authStore.isValid)` before adapter init to check auth state.
Import the schema from 'schema/pocketbase.collections.json' into PocketBase admin (Settings > Import collections). Ensure collection names match 'usePlural' setting.