Automatically expires and revokes Better Auth sessions after a configurable period of user inactivity. Current stable version is 1.0.1, released in 2025. The plugin tracks activity via a global request hook, throttles database writes (default 60s cooldown) to prevent write-locking on rapid requests, and deletes the session on timeout. It requires TypeScript 5+ and Better Auth ^1.6.11. Key differentiator: lightweight, zero-dependency plugin model vs custom middleware solutions; tightly integrated with Better Auth's session lifecycle.
npm install better-auth-idle-timeoutNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Add idle timeout plugin to Better Auth server config with defaults, then run database migration.
Ensure your auth system handles deleted sessions gracefully (e.g., triggers session creation on next login).
Ensure Better Auth's session cookie is configured and signed correctly.
Monitor the GitHub repository for updates.
Set updateThrottleSeconds to 0 to disable throttling, but be aware of increased database load.
Run 'npm install better-auth-idle-timeout' (or bun/pnpm equivalent).
User needs to re-authenticate. Increase timeoutMinutes if too aggressive.
Ensure 'idleTimeout()' is included in the 'plugins' array. Check that your tsconfig includes the plugin's types (automatic with npm).
Run 'npx better-auth migrate' or manually add the column: ALTER TABLE session ADD COLUMN lastActivityAt TIMESTAMP;