how to return more data from `/get-session`

hello, I would want to store user's balance inside session object, instead of fetching it manually

I tried to create a plugin for better auth, but it doesn't work (it worked a few days before, I didn't change code nor updated dependencies...)
import type { BetterAuthClientPlugin } from "better-auth/client";
import type { BetterAuthPlugin } from "better-auth/plugins";

export const balancePlugin = () => {
  return {
    id: "balance",
    schema: {
      user: {
        fields: {
          balance: {
            type: "number",
            required: false,
            sortable: false,
            unique: false,
            returned: true,
          },
        },
      },
    },
  } satisfies BetterAuthPlugin;
};

export const balanceClientPlugin = () => {
  return {
    id: "balance",
    $InferServerPlugin: {} as ReturnType<typeof balancePlugin>,
  } satisfies BetterAuthClientPlugin;
};


so my question is, how to store more data in the session object?
Was this page helpful?