Registry / auth-security / better-auth-organization-member

better-auth-organization-member

JSON →
library1.0.9jsnpmunverified

A Better Auth plugin that extends the organization plugin with member update capabilities and automatic hook injection for invitation-to-member data transfer. Version 1.0.9 requires better-auth >= 1.4.9 and the organization plugin. Ships TypeScript types, supports additional fields (firstName, lastName, avatar, custom) with full type inference via inferOrgMemberAdditionalFields. Key differentiators: no manual hooks, automatic afterAcceptInvitation hook injection, lifecycle hooks for before/after update, and both server and client packages.

npm install better-auth-organization-member
INSTALL
IMPORT
SIG · BETTER-AUTH-ORGANI
B
better-auth-organization-member
auth-securityjavascriptv1.0.9
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

organizationMember
✓ import { organizationMember } from 'better-auth-organization-member'
✗ const { organizationMember } = require('better-auth-organization-member')
ESM-only since v1; ships types
organizationMemberClient
✓ import { organizationMemberClient } from 'better-auth-organization-member/client'
✗ import { organizationMemberClient } from 'better-auth-organization-member'
Client-side plugin is in /client subpath; not exported from main entry
inferOrgMemberAdditionalFields
✓ import { inferOrgMemberAdditionalFields } from 'better-auth-organization-member/client'
✗ import { inferOrgMemberAdditionalFields } from 'better-auth-organization-member'
Helper for full type inference, exported from /client only

Shows server and client setup with custom additional fields, automatic hook injection, and member update call.

import { betterAuth } from 'better-auth'; import { organization } from 'better-auth/plugins'; import { organizationMember } from 'better-auth-organization-member'; export const auth = betterAuth({ plugins: [ organization({ schema: { member: { additionalFields: { firstName: { type: 'string', input: true, required: false }, lastName: { type: 'string', input: true, required: false }, avatar: { type: 'string', input: true, required: false }, }, }, invitation: { additionalFields: { firstName: { type: 'string', input: true, required: false }, lastName: { type: 'string', input: true, required: false }, avatar: { type: 'string', input: true, required: false }, }, }, }, }), organizationMember({ schema: { member: { additionalFields: { firstName: { type: 'string', input: true, required: false }, lastName: { type: 'string', input: true, required: false }, avatar: { type: 'string', input: true, required: false }, }, } }, organizationMemberHooks: { async beforeUpdateMember(data) { return { data: { ...data.updates } }; }, }, }), ], }); // Client setup import { createAuthClient } from 'better-auth/client'; import { organizationClient } from 'better-auth/client/plugins'; import { organizationMemberClient, inferOrgMemberAdditionalFields } from 'better-auth-organization-member/client'; import type { auth } from './auth'; const client = createAuthClient({ plugins: [ organizationClient({ schema: inferOrgMemberAdditionalFields<typeof auth>() }), organizationMemberClient({ schema: inferOrgMemberAdditionalFields<typeof auth>() }) ], }); // Update member await client.organization.updateMember({ memberId: 'member-id', data: { role: 'admin', firstName: 'Jane', lastName: 'Doe', avatar: 'https://example.com/avatar.png' } });
Debug
Known issues
gotchaorganizationMember plugin must be added after the organization plugin; else hook injection may fail or cause unexpected behavior
fix
Ensure organization plugin is listed first in the plugins array, then organizationMember
affects: >=1.0.0
gotchaClient plugin (organizationMemberClient) must import from 'better-auth-organization-member/client', not the main package; main package does not export client functions
fix
Use import { organizationMemberClient } from 'better-auth-organization-member/client'
affects: >=1.0.0
gotchaType inference helper inferOrgMemberAdditionalFields requires TypeScript and the auth object type to be imported; if auth type is not available, schema must be defined manually
fix
Either import type { auth } from './auth' and pass to generic, or define schema object manually
affects: >=1.0.0
breakingPlugin is ESM-only; CommonJS require() will fail with ERR_REQUIRE_ESM
fix
Use dynamic import() or switch project to ESM; set 'type': 'module' in package.json
affects: >=1.0.0
deprecatedNode engines specified >=22; older Node versions will fail to install or run
fix
Upgrade Node to version 22 or later
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require() on ESM-only package better-auth-organization-member
fix
Change to import statement or use dynamic import(). Also ensure 'type': 'module' in package.json
TypeError: Cannot read properties of undefined (reading 'additionalFields')
organizationMember plugin not added after organization plugin, or organization plugin missing schema
fix
Add organization plugin before organizationMember, and define schema for member.additionalFields if using custom fields
Module not found: Error: Can't resolve 'better-auth-organization-member/client'
Missing installation or incorrect path; package must be installed
fix
Run npm install better-auth-organization-member. If using TypeScript, ensure moduleResolution is set to bundler or node16
TypeScript error: Type '{}' is not assignable to type 'InferOrgMemberAdditionalFields<AuthType>'
Passing auth object type incorrectly; inferOrgMemberAdditionalFields expects a generic type parameter
fix
Use inferOrgMemberAdditionalFields<typeof auth>() properly; ensure auth is exported as a type
Error: afterAcceptInvitation hook already exists
Manually defining afterAcceptInvitation hook in organization plugin conflicts with automatic injection
fix
Remove manually defined afterAcceptInvitation hook from organization plugin config; let organizationMember handle it
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies
@better-auth/oauth-providerrequiredPeer dependency; required for OAuth provider integration
better-authrequiredPeer dependency; core authentication library
Agent activity
26 hits · last 30 days
node
20
OpenAI (training)
1
Resources
better-auth-organization-member — npm install better-auth-organization-member · libregistry