Better Auth supports running without a database using encrypted cookie sessions (JWE).
Database-less mode uses JWE (JSON Web Encryption) sessions. Instead of storing sessions in a database, the session data is encrypted and stored entirely in the cookie.
How it works:
BETTER_AUTH_SECRETYou cannot invalidate a session before it expires. The user must wait for the cookie to expire.
Workaround: Use short session lifetimes (e.g., 1 hour) and implement token refresh.
Email/password requires storing user credentials somewhere.
Workaround:
Cannot list or revoke sessions across devices.
Workaround: Implement device tracking in your application layer if needed.
Simply don't configure a database adapter:
export default defineNuxtConfig({
modules: ['@onmax/nuxt-better-auth'],
})
Enable JWE sessions and cookie-based OAuth state:
import { defineServerAuth } from '@onmax/nuxt-better-auth/config'
export default defineServerAuth({
socialProviders: {
github: { clientId: '...', clientSecret: '...' },
},
session: {
cookieCache: {
enabled: true,
maxAge: 7 * 24 * 60 * 60, // 7 days
strategy: 'jwe',
},
},
account: {
storeStateStrategy: 'cookie',
storeAccountCookie: true,
},
})
This stores sessions and OAuth state in encrypted cookies instead of a database.
Good fit:
Not recommended: