An offline-first plugin for better-auth v1+ that caches auth API responses in IndexedDB, allowing apps to function without network connectivity. Released as v0.0.2 (latest) with patch-level updates. Automatically caches allowlisted GET endpoints (e.g., /get-session) and serves cached data when network fails. Includes configurable allowlist, custom storage adapters, online status tracking, and SSR support. Differentiates from generic caching libraries by being a drop-in plugin for better-auth, handling cache invalidation on sign-in/sign-out to prevent cross-user data leaks, and adding an X-Offline-Cache header for detection.
npm install better-auth-offlineVerified import paths — ran on the pinned version, not inferred.
Quick setup of better-auth-offline plugin with better-auth client, enabling automatic caching of auth API responses for offline use.
Stay updated with releases; check changelog for breaking changes.
Use the header only for UI indicators (e.g., 'showing cached data').
Do not expect mutation responses to be served offline.
Ensure better-auth is at version 1.0.0 or higher.
Install the package: npm install better-auth-offline. Ensure tsconfig.json includes moduleResolution: 'node' or 'bundler'.
Use named import: import { offlinePlugin } from 'better-auth-offline';Add offlinePlugin() to the plugins array when creating auth client.