|
1 | 1 | # better-auth-convex |
2 | 2 |
|
| 3 | +## 0.5.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- [#30](https://github.com/udecode/better-auth-convex/pull/30) [`cc1ca02`](https://github.com/udecode/better-auth-convex/commit/cc1ca028d8f494e25a53555fe4b9fe120b895ced) Thanks [@zbeyens](https://github.com/zbeyens)! - ### @convex-dev/better-auth 0.10 |
| 8 | + |
| 9 | + This release updates better-auth-convex to work with `@convex-dev/better-auth@0.10.4` and `better-auth@1.4.7`. |
| 10 | + |
| 11 | + For the upstream migration guide, see: https://labs.convex.dev/better-auth/migrations/migrate-to-0-10 |
| 12 | + |
| 13 | + ### Breaking Changes |
| 14 | + |
| 15 | + #### `createApi` signature changed |
| 16 | + |
| 17 | + The second parameter is now `createAuth` function instead of spread auth options: |
| 18 | + |
| 19 | + ```ts |
| 20 | + // Before |
| 21 | + export const { create, ... } = createApi(schema, { |
| 22 | + ...auth.options, |
| 23 | + skipValidation: true, |
| 24 | + }); |
| 25 | + |
| 26 | + // After |
| 27 | + export const { create, ... } = createApi(schema, createAuth, { |
| 28 | + skipValidation: true, |
| 29 | + }); |
| 30 | + ``` |
| 31 | + |
| 32 | + #### `authClient.adapter` signature changed |
| 33 | + |
| 34 | + Now takes `createAuthOptions` function instead of options object: |
| 35 | + |
| 36 | + ```ts |
| 37 | + // Before |
| 38 | + database: authClient.adapter(ctx, auth.options), |
| 39 | + |
| 40 | + // After |
| 41 | + database: authClient.adapter(ctx, createAuthOptions), |
| 42 | + ``` |
| 43 | + |
| 44 | + #### `createAuth` pattern replaced |
| 45 | + |
| 46 | + The static `auth` instance with `optionsOnly` is replaced by `createAuthOptions` factory: |
| 47 | + |
| 48 | + ```ts |
| 49 | + // Before |
| 50 | + export const createAuth = (ctx, { optionsOnly } = { optionsOnly: false }) => { |
| 51 | + return betterAuth({ ... }); |
| 52 | + }; |
| 53 | + export const auth = createAuth({}, { optionsOnly: true }); |
| 54 | + |
| 55 | + // After |
| 56 | + export const createAuthOptions = (ctx) => ({ |
| 57 | + baseURL: process.env.SITE_URL!, |
| 58 | + plugins: [convex({ authConfig, jwks: process.env.JWKS })], |
| 59 | + // ... |
| 60 | + }) satisfies BetterAuthOptions; |
| 61 | + |
| 62 | + export const createAuth = (ctx) => betterAuth(createAuthOptions(ctx)); |
| 63 | + ``` |
| 64 | + |
| 65 | + ### New Features |
| 66 | + |
| 67 | + #### Static JWKS exports |
| 68 | + |
| 69 | + `createApi` now exports `getLatestJwks` and `rotateKeys` for static JWKS management: |
| 70 | + |
| 71 | + ```ts |
| 72 | + export const { |
| 73 | + create, |
| 74 | + // ... other exports |
| 75 | + getLatestJwks, |
| 76 | + rotateKeys, |
| 77 | + } = createApi(schema, createAuth, { skipValidation: true }); |
| 78 | + ``` |
| 79 | + |
| 80 | + After deploying, generate JWKS: |
| 81 | + |
| 82 | + ```bash |
| 83 | + npx convex run auth:getLatestJwks | npx convex env set JWKS |
| 84 | + ``` |
| 85 | + |
| 86 | + ### Migration Steps |
| 87 | + 1. Update dependencies: |
| 88 | + |
| 89 | + ```bash |
| 90 | + pnpm add better-auth@1.4.7 @convex-dev/better-auth@0.10.4 |
| 91 | + ``` |
| 92 | + |
| 93 | + 2. Update `convex/auth.config.ts`: |
| 94 | + |
| 95 | + ```ts |
| 96 | + export default { |
| 97 | + providers: [getAuthConfigProvider({ jwks: process.env.JWKS })], |
| 98 | + } satisfies AuthConfig; |
| 99 | + ``` |
| 100 | + |
| 101 | + 3. Update `convex/auth.ts`: |
| 102 | + - Replace `auth` static instance with `createAuthOptions` factory |
| 103 | + - Update `createApi` call signature |
| 104 | + - Update `getAuth` to use `createAuthOptions` |
| 105 | + - Add `getLatestJwks` and `rotateKeys` to exports |
| 106 | + 4. Deploy and generate JWKS: |
| 107 | + ```bash |
| 108 | + npx convex run auth:getLatestJwks | npx convex env set JWKS |
| 109 | + ``` |
| 110 | + |
| 111 | + See the [README](https://github.com/udecode/better-auth-convex) for complete setup examples. |
| 112 | + |
3 | 113 | ## 0.4.9 |
4 | 114 |
|
5 | 115 | ### Patch Changes |
|
0 commit comments