{"id":18156,"library":"better-auth-organization-member","title":"better-auth-organization-member","description":"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.","status":"active","version":"1.0.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install better-auth-organization-member","lang":"bash","label":"npm"},{"cmd":"yarn add better-auth-organization-member","lang":"bash","label":"yarn"},{"cmd":"pnpm add better-auth-organization-member","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required for OAuth provider integration","package":"@better-auth/oauth-provider","optional":false},{"reason":"Peer dependency; core authentication library","package":"better-auth","optional":false}],"imports":[{"note":"ESM-only since v1; ships types","wrong":"const { organizationMember } = require('better-auth-organization-member')","symbol":"organizationMember","correct":"import { organizationMember } from 'better-auth-organization-member'"},{"note":"Client-side plugin is in /client subpath; not exported from main entry","wrong":"import { organizationMemberClient } from 'better-auth-organization-member'","symbol":"organizationMemberClient","correct":"import { organizationMemberClient } from 'better-auth-organization-member/client'"},{"note":"Helper for full type inference, exported from /client only","wrong":"import { inferOrgMemberAdditionalFields } from 'better-auth-organization-member'","symbol":"inferOrgMemberAdditionalFields","correct":"import { inferOrgMemberAdditionalFields } from 'better-auth-organization-member/client'"}],"quickstart":{"code":"import { betterAuth } from 'better-auth';\nimport { organization } from 'better-auth/plugins';\nimport { organizationMember } from 'better-auth-organization-member';\n\nexport const auth = betterAuth({\n  plugins: [\n    organization({\n      schema: {\n        member: {\n          additionalFields: {\n            firstName: { type: 'string', input: true, required: false },\n            lastName: { type: 'string', input: true, required: false },\n            avatar: { type: 'string', input: true, required: false },\n          },\n        },\n        invitation: {\n          additionalFields: {\n            firstName: { type: 'string', input: true, required: false },\n            lastName: { type: 'string', input: true, required: false },\n            avatar: { type: 'string', input: true, required: false },\n          },\n        },\n      },\n    }),\n    organizationMember({\n      schema: {\n        member: {\n          additionalFields: {\n            firstName: { type: 'string', input: true, required: false },\n            lastName: { type: 'string', input: true, required: false },\n            avatar: { type: 'string', input: true, required: false },\n          },\n        }\n      },\n      organizationMemberHooks: {\n        async beforeUpdateMember(data) {\n          return { data: { ...data.updates } };\n        },\n      },\n    }),\n  ],\n});\n\n// Client setup\nimport { createAuthClient } from 'better-auth/client';\nimport { organizationClient } from 'better-auth/client/plugins';\nimport { organizationMemberClient, inferOrgMemberAdditionalFields } from 'better-auth-organization-member/client';\nimport type { auth } from './auth';\n\nconst client = createAuthClient({\n  plugins: [\n    organizationClient({\n      schema: inferOrgMemberAdditionalFields<typeof auth>()\n    }),\n    organizationMemberClient({\n      schema: inferOrgMemberAdditionalFields<typeof auth>()\n    })\n  ],\n});\n\n// Update member\nawait client.organization.updateMember({\n  memberId: 'member-id',\n  data: {\n    role: 'admin',\n    firstName: 'Jane',\n    lastName: 'Doe',\n    avatar: 'https://example.com/avatar.png'\n  }\n});","lang":"typescript","description":"Shows server and client setup with custom additional fields, automatic hook injection, and member update call."},"warnings":[{"fix":"Ensure organization plugin is listed first in the plugins array, then organizationMember","message":"organizationMember plugin must be added after the organization plugin; else hook injection may fail or cause unexpected behavior","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import { organizationMemberClient } from 'better-auth-organization-member/client'","message":"Client plugin (organizationMemberClient) must import from 'better-auth-organization-member/client', not the main package; main package does not export client functions","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either import type { auth } from './auth' and pass to generic, or define schema object manually","message":"Type inference helper inferOrgMemberAdditionalFields requires TypeScript and the auth object type to be imported; if auth type is not available, schema must be defined manually","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use dynamic import() or switch project to ESM; set 'type': 'module' in package.json","message":"Plugin is ESM-only; CommonJS require() will fail with ERR_REQUIRE_ESM","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade Node to version 22 or later","message":"Node engines specified >=22; older Node versions will fail to install or run","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change to import statement or use dynamic import(). Also ensure 'type': 'module' in package.json","cause":"Using require() on ESM-only package better-auth-organization-member","error":"ERR_REQUIRE_ESM"},{"fix":"Add organization plugin before organizationMember, and define schema for member.additionalFields if using custom fields","cause":"organizationMember plugin not added after organization plugin, or organization plugin missing schema","error":"TypeError: Cannot read properties of undefined (reading 'additionalFields')"},{"fix":"Run npm install better-auth-organization-member. If using TypeScript, ensure moduleResolution is set to bundler or node16","cause":"Missing installation or incorrect path; package must be installed","error":"Module not found: Error: Can't resolve 'better-auth-organization-member/client'"},{"fix":"Use inferOrgMemberAdditionalFields<typeof auth>() properly; ensure auth is exported as a type","cause":"Passing auth object type incorrectly; inferOrgMemberAdditionalFields expects a generic type parameter","error":"TypeScript error: Type '{}' is not assignable to type 'InferOrgMemberAdditionalFields<AuthType>'"},{"fix":"Remove manually defined afterAcceptInvitation hook from organization plugin config; let organizationMember handle it","cause":"Manually defining afterAcceptInvitation hook in organization plugin conflicts with automatic injection","error":"Error: afterAcceptInvitation hook already exists"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}