better-auth-firestore
llms.txt10 starsChanged 3 months agoMITView on GitHub
Firestore database adapter for Better Auth using the Firebase Admin SDK — a drop-in replacement for the Auth.js Firebase adapter. Install: pnpm add better-auth-firestore firebase-admin better-auth Agent skill: npx skills add yultyyev/better-auth-firestore This package stores Better Auth users, sessions, accounts, and verification tokens in Firestore. Pair with better-auth-firebase-auth when you also need Firebase Authentication (Phone OTP, Google, Email/Password).
- Installs packages
In this repository2 other files it gives its agents.
- AGENTS.mdAGENTS.md
- firestore-better-authSkill
The file
Files
# better-auth-firestore > Firestore database adapter for Better Auth using the Firebase Admin SDK — a drop-in replacement for the Auth.js Firebase adapter. Install: `pnpm add better-auth-firestore firebase-admin better-auth` Agent skill: `npx skills add yultyyev/better-auth-firestore` This package stores Better Auth users, sessions, accounts, and verification tokens in Firestore. Pair with [better-auth-firebase-auth](https://github.com/yultyyev/better-auth-firebase-auth) when you also need Firebase Authentication (Phone OTP, Google, Email/Password). ## Documentation - [README](https://github.com/yultyyev/better-auth-firestore/blob/main/README.md): Full setup guide, options, migration, emulator, troubleshooting, and FAQ - [AI Assistant Skill (SKILL.md)](https://github.com/yultyyev/better-auth-firestore/blob/main/skills/firestore-better-auth/SKILL.md): Agent instructions for setup, index creation, env vars, and common mistakes - [AGENTS.md](https://github.com/yultyyev/better-auth-firestore/blob/main/AGENTS.md): Project context for AI assistants working on this codebase - [CONTRIBUTING.md](https://github.com/yultyyev/better-auth-firestore/blob/main/CONTRIBUTING.md): Development and contribution guidelines - [Minimal Next.js example](https://github.com/yultyyev/better-auth-firestore/tree/main/examples/minimal): Working App Router integration ## Package & ecosystem - [npm: better-auth-firestore](https://www.npmjs.com/package/better-auth-firestore): Published package - [skills.sh listing](https://skills.sh/yultyyev/better-auth-firestore): Agent skill directory (indexed after install telemetry) - [better-auth-firebase-auth](https://github.com/yultyyev/better-auth-firebase-auth): Sister plugin for Firebase Auth identity providers - [Better Auth docs](https://www.better-auth.com/docs): Framework documentation - [Better Auth adapter guide](https://www.better-auth.com/docs/guides/create-a-db-adapter): How database adapters work - [Better Auth 1.7 upgrade guide](https://better-auth.com/docs/guides/1-7-upgrade-guide): Official upgrade steps (account identity backfill, breaking changes) ## Key topics for AI assistants - No Firestore composite index required (v1.1+): the adapter applies `where` filters server-side and sorts in memory, so verification-token lookups (`identifier ==` ordered by `createdAt desc`) need only automatic single-field indexes. As of v1.3 this includes `rateLimit.storage: "database"` — the native `incrementOne` sends only equality filters to Firestore. A `9 FAILED_PRECONDITION: The query requires an index` error means the project is on an older version — upgrade rather than creating the index. `generateIndexSetupUrl(projectId)` / `getIndexConfig()` remain as optional helpers. - Better Auth 1.7 support (adapter v1.3+): 1.7 requires native `incrementOne`/`consumeOne` (both implemented; the same release works with 1.6) and identifies accounts by `(issuer, accountId)`. Existing deployments must run `npx better-auth-firestore backfill-account-issuers` (dry run) then `--apply` before deploying 1.7, otherwise existing users cannot sign in; the adapter warns at startup with that command when account documents lack `issuer` (`migrationChecks: false` disables it). Programmatic form: `backfillAccountIssuers()`. `Adapter "firestore" must implement incrementOne` means the adapter is older than v1.3. - `FIREBASE_PRIVATE_KEY` env vars often contain literal `\n` — call `.replace(/\\n/g, "\n")` before passing to `cert()` - Node.js runtimes only — Firebase Admin SDK does not run on Vercel Edge or Cloudflare Workers (default Vercel serverless Node.js is supported) - Migration from Auth.js/NextAuth: same default collection names and field shapes, no Firestore data migration needed - Local dev and tests: set `FIRESTORE_EMULATOR_HOST=localhost:8080` — no credentials required with the emulator ## Optional - [Auth.js Firebase adapter (legacy)](https://authjs.dev/getting-started/adapters/firebase): Original adapter this package replaces - [Auth.js joins Better Auth](https://www.better-auth.com/blog/authjs-joins-better-auth): Migration context - [Firestore emulator docs](https://firebase.google.com/docs/emulator-suite/connect_firestore): Official Firebase emulator setup
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

