Skip to main content

Function: createFlashcoreAdapter()

function createFlashcoreAdapter(options): PasswordAdapter

Creates a password-capable Auth.js adapter that stores users, accounts, sessions, verification tokens, and password hashes inside Flashcore namespaces. Supports the full PasswordAdapter contract including helper utilities such as listUserIds and listUsers for admin tooling.

Security:

  • ⚠️ Verification tokens are hashed with SHA-256 via hashToken before storage to prevent leakage if Flashcore is compromised.
  • ⚠️ Passwords are hashed by the configured PasswordHasher (default Argon2id) before reaching the adapter. Plaintext passwords are never stored.
  • ⚠️ Email addresses are normalized to lowercase before indexing to ensure case-insensitive lookups. Keep your application-side normalization in sync.

Performance:

  • Most adapter methods require 1–3 Flashcore operations. Consider caching session data for extremely high traffic deployments.
  • User pagination defaults to 500 users per page; adjust downstream tooling or rebuild the index if different sizing is required.

Edge cases:

  • Concurrent user creation with the same email can produce duplicates; implement application-level locking if this is a concern.
  • Deleting a user cascades removal of accounts, sessions, passwords, and pagination indexes—this is irreversible.
  • getSessionAndUser prunes expired sessions on read, so concurrent requests might observe brief inconsistencies.

Parameters

ParameterTypeDescription
optionsFlashcoreAdapterOptionsRequires a secret for hashing tokens. Must match the Auth.js config secret.

Returns

PasswordAdapter

PasswordAdapter implementation with Flashcore-backed persistence.

Examples

const adapter = createFlashcoreAdapter({ secret: process.env.AUTH_SECRET! })
export default {
adapter: createFlashcoreAdapter({ secret: process.env.AUTH_SECRET! }),
providers: [...]
}
try {
createFlashcoreAdapter({ secret: process.env.AUTH_SECRET! })
} catch (error) {
console.error('Adapter initialization failed', error)
}

See

PasswordAdapter in src/builtins/email-password/types.ts