Custom session plugin in monorepo

I have a monorepo with 2 projects
client
and
server
. Both have their own
package.json
and tsconfijg.json. On the server I have configured better-auth to provide a custom session:
export const auth = betterAuth({
  /* ... */
  plugins: [
    customSession(async ({ user, session }) => {
      let role = "USER";
      if (AppConfig.administrators.includes(user.email!)) {
        role = "ADMIN";
      }

      return {
        session,
        user: {
          ...user,
          role,
        },
      };
    }),
  ],
});

On the client I'm doing this as per the docs
import { customSessionClient } from "better-auth/client/plugins";
import type { auth } from "@/lib/auth"; // Import the auth instance as a type
const authClient = createAuthClient({
    plugins: [customSessionClient<typeof auth>()],
});

Essentially I'm getting weird type errors such as
Type `(ctx: HookEndpointContext) => boolean` is not assignable to type
     `(ctx: HookEndpointContext) => boolean`

since they seem to be imported from different dynamically generated files:
import("~/node_modules/better-auth/dist/shared/better-auth.BBLxGH6k").H
import("~/node_modules/better-auth/dist/shared/better-auth.DZfsKi2z").H


Is there a way to generate only a single .d.ts for generated better-auth types so I don't have these compatbility issues between projects? It seems like currently it generates one for each project that consumes anything from better-auth.
Was this page helpful?