Registry /
auth-security / better-auth-no-disposable-emails
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
noDisposableEmails
✓ import { noDisposableEmails } from 'better-auth-no-disposable-emails';
✗ const noDisposableEmails = require('better-auth-no-disposable-emails').noDisposableEmails;
The library primarily targets ESM environments and ships with TypeScript types. While CJS is possible, ESM is the idiomatic way to import.
noDisposableEmails (default options)
✓ import { noDisposableEmails } from 'better-auth-no-disposable-emails';
// ... plugins: [noDisposableEmails()]
✗ import { noDisposableEmails } from 'better-auth-no-disposable-emails';
// ... plugins: [noDisposableEmails]
The `noDisposableEmails` function must be called to return the plugin instance, even when using default options.
noDisposableEmails (with options)
✓ import { noDisposableEmails } from 'better-auth-no-disposable-emails';
// ... plugins: [noDisposableEmails({ errorMessage: '...' })]
Options are passed as an object to the function call.
This quickstart demonstrates how to initialize `better-auth` and integrate the `noDisposableEmails` plugin, configuring it with a custom error message, additional blocked domains, and specific interception paths.
import { betterAuth } from "better-auth";
import { noDisposableEmails } from "better-auth-no-disposable-emails";
// Mock database adapter for demonstration purposes
const mockDatabaseAdapter = {
getUserByEmail: async (email: string) => {
if (email === 'test@example.com') return { id: '1', email: 'test@example.com' };
return null;
},
createUser: async (email: string, passwordHash: string) => ({
id: String(Date.now()),
email,
}),
updateUser: async (id: string, updates: any) => ({ id, ...updates }),
// Add other necessary methods for a better-auth database adapter
};
export const auth = betterAuth({
database: mockDatabaseAdapter, // Replace with your actual database adapter
emailAndPassword: {
enabled: true,
// In a real app, you'd configure password hashing, JWTs, etc.
getHash: async (password: string) => password + '_hashed', // Placeholder
verifyHash: async (password: string, hash: string) => (password + '_hashed') === hash // Placeholder
},
plugins: [
noDisposableEmails({
errorMessage: "Please use a permanent email address for registration.",
customBlockedDomains: ["temporary.io", "spammail.net"],
paths: ["/sign-up/email", "/sign-in/magic-link"]
}),
],
// ... other better-auth configuration
});
console.log("better-auth instance with disposable email plugin configured.");
console.log("Plugin paths: /sign-up/email, /sign-in/magic-link");
Errors
Common errors & fixes
TypeError: noDisposableEmails is not a function or its return value is not a plugin.
The `noDisposableEmails` plugin function was added to the `plugins` array without being invoked.
fixCall the function: `plugins: [noDisposableEmails()]` or `plugins: [noDisposableEmails({...options})]`. Error: Peer dependency 'better-auth@>=1.5.0' not met.
The `better-auth` package is not installed or its version is older than required.
fixInstall or update better-auth: `npm install better-auth@latest`
400 BAD_REQUEST - DISPOSABLE_EMAIL_NOT_ALLOWED
A user attempted to register or sign in with an email address detected as disposable. This is the expected behavior of the plugin.
fixInform the user that temporary email addresses are not accepted. The default `errorMessage` or a custom one will be sent to the client. No code change is necessary if this behavior is desired.
Disposable email passes through on /sign-in/email
The `noDisposableEmails` plugin's `paths` option does not include `/sign-in/email`.
fixUpdate the plugin configuration to include the desired paths: `noDisposableEmails({ paths: ["/sign-up/email", "/sign-in/email"] })`. Audit
Dependencies
better-authrequiredThis is a plugin for better-auth and requires it to function.
mailcheckerrequiredUsed internally for disposable email detection, but not a direct peer dependency.