| 1 | import { createAuthClient } from "better-auth/react"; |
| 2 | import { ac, roles } from "@ghost/permissions"; |
| 3 | import { organizationClient, usernameClient } from "better-auth/client/plugins"; |
| 4 | import { apiKeyClient } from "@better-auth/api-key/client"; |
| 5 | |
| 6 | import { API_URL } from "@/lib/env"; |
| 7 | |
| 8 | export const authClient = createAuthClient({ |
| 9 | baseURL: API_URL, |
| 10 | basePath: "/api/auth", |
| 11 | plugins: [ |
| 12 | usernameClient(), |
| 13 | apiKeyClient(), |
| 14 | // Mirrors the server's organization plugin, so the client knows the same roles. |
| 15 | organizationClient({ |
| 16 | ac, |
| 17 | roles, |
| 18 | teams: { enabled: true }, |
| 19 | dynamicAccessControl: { enabled: true }, |
| 20 | }), |
| 21 | ], |
| 22 | }); |