Betterauth Pocketbase

Web Development
nodejs
pocketbase
authentification
open source

Images

BEST-MACBOOKS-325.png

Description

Overview

pocketbase-better-auth is a specialized integration layer designed to combine the modern authentication capabilities of Better Auth with the ease of use of PocketBase. While PocketBase offers built-in auth, many developers require the advanced features of Better Auth (multi-framework support, extensive plugins, and granular session control) but still want to keep their data within the PocketBase ecosystem.

This adapter serves as the translation engine, allowing Better Auth to perform CRUD operations, session management, and user verification directly against a PocketBase instance, seamlessly handling the translation between SQL-like logic and PocketBase's API filter syntax.

Highlights

  • Seamless Interoperability: Implements the full Better Auth adapter interface, enabling features like session management, OAuth linking, and email verification using PocketBase collections.
  • Advanced Query Parsing: Features a custom query translator that converts complex Better Auth Where clauses into PocketBase’s specific filter syntax.
  • TypeScript First: Built entirely in TypeScript with complete type definitions for developer safety and autocompletion.
  • Rapid Onboarding: Includes pre-configured JSON schema files (pocketbase.collections.json), allowing developers to instantly import the required user, session, and account structures into their database.

My Role

  • Core Architecture: Designed and built the adapter from scratch to map Better Auth’s abstract database calls to PocketBase’s REST API.
  • Query Logic Implementation: Engineered the parseWhere utility to reliably translate complex JSON-based query objects into PocketBase-compatible string filters.
  • Testing & Quality Assurance: Wrote over 17 unit tests to ensure stability across CRUD operations, error handling, and edge cases.
  • Documentation & Community: Created comprehensive documentation, including setup guides, security best practices (handling Admin API tokens), and schema import instructions.

Outcome

  • Delivered a production-ready npm package that simplifies the tech stack for developers using Next.js/Express with PocketBase.
  • Solved a key ecosystem fragmentation issue by allowing the use of advanced auth frameworks without abandoning PocketBase as a backend.
  • Provided a robust, fully typed solution that handles secure server-side admin authentication without exposing credentials to the client.

Technologies & Skills

nodejs
pocketbase
authentification
open source
Betterauth Pocketbase | Bréval Le Floch - Creative Developer