inferring types on the client, based on plugins added on the server

I have a monorepo, with the admin plugin added to the server initialization of betterAuth. I was expecting the additional user properties, like role would be accessible from session.user.

Here's my server code:
export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: 'pg',
    schema,
    usePlural: true,
  }),
  emailAndPassword: {
    enabled: true,
  },
  plugins: [admin()],
});


And this is the auth client on the frontend:
export const authClient = createAuthClient({
  plugins: [inferAdditionalFields<typeof auth>()],
});


Then, when trying to access the role property from the session.user object, I get:

Property 'role' does not exist on type '{ id: string; name: string; email: string; emailVerified: boolean; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }'.ts(2339)


FWIW, I can do the following on the client, and I get the actual shape of User:
type Session = Awaited<ReturnType<typeof auth.api.getSession>>;
type User = NonNullable<Session>['user'];


What's the right approach to get the User shape in the client side in the session object?
Was this page helpful?