@delmaredigital/payload-better-auth 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +1,51 @@
1
1
  /**
2
2
  * Client-side auth utilities
3
- * Re-exports createAuthClient from better-auth/react and common plugins
3
+ * Re-exports createAuthClient from better-auth/react and core plugins
4
+ *
5
+ * NOTE: Only plugins from the core `better-auth` package are statically imported here.
6
+ * Optional peer dep plugins (passkey, apiKey, etc.) must NOT be statically imported
7
+ * because webpack resolves all static imports at build time, breaking consumers
8
+ * who don't have those packages installed.
4
9
  */ import { createAuthClient } from 'better-auth/react';
5
10
  import { twoFactorClient } from 'better-auth/client/plugins';
6
- import { apiKeyClient } from '@better-auth/api-key/client';
7
- import { passkeyClient } from '@better-auth/passkey/client';
8
- // Re-export createAuthClient and common plugins
11
+ // Re-export createAuthClient and core plugins
9
12
  export { createAuthClient } from 'better-auth/react';
10
13
  export { twoFactorClient } from 'better-auth/client/plugins';
11
- export { apiKeyClient } from '@better-auth/api-key/client';
12
- export { passkeyClient } from '@better-auth/passkey/client';
13
14
  /**
14
- * Default plugins included with Payload Better Auth.
15
- * Use this with createAuthClient when you need custom plugins with full type safety.
15
+ * Default plugins included with Payload Better Auth (core only).
16
+ * Add optional plugins (passkeyClient, apiKeyClient) from their own packages.
16
17
  *
17
- * @example With custom plugins (full type safety)
18
+ * @example
18
19
  * ```typescript
19
20
  * import { createAuthClient, payloadAuthPlugins } from '@delmaredigital/payload-better-auth/client'
20
- * import { stripeClient } from '@better-auth/stripe/client'
21
+ * import { passkeyClient } from '@better-auth/passkey/client'
22
+ * import { apiKeyClient } from '@better-auth/api-key/client'
21
23
  *
22
24
  * export const authClient = createAuthClient({
23
- * plugins: [...payloadAuthPlugins, stripeClient({ subscription: true })],
25
+ * plugins: [...payloadAuthPlugins, passkeyClient(), apiKeyClient()],
24
26
  * })
25
- *
26
- * // authClient.subscription is fully typed!
27
27
  * ```
28
28
  */ export const payloadAuthPlugins = [
29
- twoFactorClient(),
30
- apiKeyClient(),
31
- passkeyClient()
29
+ twoFactorClient()
32
30
  ];
33
31
  /**
34
- * Create a pre-configured auth client with default plugins (twoFactor, apiKey, passkey).
32
+ * Create a pre-configured auth client with default core plugins (twoFactor).
35
33
  *
36
- * This is a convenience wrapper for simple setups. For custom plugins with full type
37
- * safety, use `createAuthClient` with `payloadAuthPlugins` instead.
34
+ * For passkeys, API keys, or other optional plugins, use `createAuthClient` directly:
38
35
  *
39
- * @param options - Optional configuration
40
- * @param options.baseURL - Base URL for auth endpoints (defaults to window.location.origin)
41
- *
42
- * @example Basic usage (no custom plugins)
36
+ * @example Basic usage
43
37
  * ```typescript
44
38
  * import { createPayloadAuthClient } from '@delmaredigital/payload-better-auth/client'
45
- *
46
39
  * export const authClient = createPayloadAuthClient()
47
40
  * ```
48
41
  *
49
- * @example With custom plugins (use createAuthClient for full type safety)
42
+ * @example With optional plugins
50
43
  * ```typescript
51
44
  * import { createAuthClient, payloadAuthPlugins } from '@delmaredigital/payload-better-auth/client'
52
- * import { stripeClient } from '@better-auth/stripe/client'
45
+ * import { passkeyClient } from '@better-auth/passkey/client'
53
46
  *
54
47
  * export const authClient = createAuthClient({
55
- * plugins: [...payloadAuthPlugins, stripeClient({ subscription: true })],
48
+ * plugins: [...payloadAuthPlugins, passkeyClient()],
56
49
  * })
57
50
  * ```
58
51
  */ export function createPayloadAuthClient(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delmaredigital/payload-better-auth",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Better Auth adapter and plugins for Payload CMS",
5
5
  "type": "module",
6
6
  "license": "MIT",