better-auth-firebase-auth is a specialized plugin designed to integrate Firebase Authentication seamlessly with the Better Auth library. Currently at version 2.0.5, it provides robust authentication capabilities, leveraging Firebase's built-in email services for password resets and verification, global infrastructure for high availability, and battle-tested security. The package maintains an active release cadence, frequently addressing security vulnerabilities and improving compatibility. It differentiates itself by simplifying the integration of Firebase's comprehensive authentication features, allowing developers to benefit from a multi-platform SDK and customizable email templates without the complexities of managing their own email infrastructure. This makes it particularly suitable for applications seeking a secure, performant, and feature-rich authentication solution with minimal setup effort, especially when existing Firebase projects are in use.
npm install better-auth-firebase-authVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the server-side setup of `better-auth-firebase-auth` within a Better Auth middleware, including Firebase Admin SDK initialization and plugin configuration. It also provides commented guidance for client-side integration.
Update `package.json` by running `npm uninstall @yultyyev/better-auth-firebase-auth && npm install better-auth-firebase-auth`. Then, globally replace `@yultyyev/better-auth-firebase-auth` with `better-auth-firebase-auth` in your import statements.
Always use `import { firebaseAuthClientPlugin } from 'better-auth-firebase-auth/client';` for browser-side code and `import { firebaseAuthPlugin } from 'better-auth-firebase-auth/server';` for server-side code. Avoid the main export `better-auth-firebase-auth` if your bundler isn't configured for environment-specific code splitting.For your own `better-auth` code, ensure you import `createAuthMiddleware` from `better-auth/api`. Update your `better-auth` peer dependency to `>=1.5.0` to leverage the latest features and import paths.
Upgrade your Node.js environment to version 22 or higher. Verify your `engines` field in `package.json` to ensure compatibility.
Ensure `initializeApp` from `firebase-admin/app` is called only once in your server-side entry point, guarded by `!getApps().length`. Verify that `process.env.FIREBASE_SERVICE_ACCOUNT_KEY` is correctly set, parsed as valid JSON, and contains the correct service account credentials for your Firebase project.
For client-side code, use `import { firebaseAuthClientPlugin } from 'better-auth-firebase-auth/client';`. Ensure `firebaseAuthPlugin` is strictly used in server environments only.Ensure your `better-auth` dependency is at least `1.5.0` and that you are importing `createAuthMiddleware` from `better-auth/api`.
Verify that your `FIREBASE_SERVICE_ACCOUNT_KEY` environment variable contains a valid JSON string of your Firebase service account credentials. Ensure it's correctly loaded and parsed when `firebase-admin` is initialized on the server.