Registry /
security / better-auth-immigration
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
legacyImmigration
✓ import { legacyImmigration } from 'better-auth-immigration'
✗ import { legacyImmigration } from 'better-auth-immigration/plugin'
Server-side plugin function; must be passed to BetterAuth plugins array.
legacyImmigrationClient
✓ import { legacyImmigrationClient } from 'better-auth-immigration/client'
✗ import { legacyImmigrationClient } from 'better-auth-immigration'
Client-side plugin function; exported from /client subpath.
authClient.legacyImmigration.exchange
✓ await authClient.legacyImmigration.exchange({ token: legacyToken })
✗ authClient.legacyImmigration({ token: legacyToken })
Method is called on the legacyImmigration property, not as a direct function.
Shows basic usage: importing server/client plugins, setting up legacy token verification and user resolution, and calling the exchange method.
import { betterAuth } from 'better-auth';
import { legacyImmigration } from 'better-auth-immigration';
import { createAuthClient } from 'better-auth/client';
import { legacyImmigrationClient } from 'better-auth-immigration/client';
// Server
const auth = betterAuth({
plugins: [
legacyImmigration({
async verifyLegacyToken(token: string) {
// Validate old JWT or token, return legacy user ID
return { legacyUserId: token };
},
async resolveTransition({ legacyUserId }: { legacyUserId: string }) {
// Map legacy user to Better Auth user ID
return { userId: legacyUserId };
},
async onMigrated({ legacyUserId }: { legacyUserId: string }) {
console.log('migrated', legacyUserId);
}
})
]
});
// Client
const authClient = createAuthClient({
plugins: [legacyImmigrationClient()]
});
// Exchange legacy token for session
const oldToken = process.env.LEGACY_TOKEN ?? '';
await authClient.legacyImmigration.exchange({ token: oldToken });
Errors
Common errors & fixes
legacyImmigration is not a function
Incorrect import path or missing default export.
fixUse import { legacyImmigration } from 'better-auth-immigration' (not a subpath). Cannot find module 'better-auth-immigration/client'
The client-side subpath is not resolved, possibly due to ESM configuration or outdated node_modules.
fixEnsure better-auth-immigration v0.1.1 is installed and your module system supports subpath exports (Node.js 16+ with ESM).
Uncaught TypeError: authClient.legacyImmigration.exchange is not a function
Client plugin not registered or misconfigured.
fixEnsure legacyImmigrationClient() is added to createAuthClient plugins array.
Audit
Dependencies
better-authrequiredpeer dependency for server-side plugin and client types