Type of listTeams is inferred as unknown[]

I am running into an issue with both frontend and backend in a TanStack Start project where the type of listTeams is inferred as unknown:
// backend
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
database: drizzleAdapter(db, {
provider: 'pg',
schema: authTables,
usePlural: true,
}),
plugins: [
organization({
teams: {
enabled: true,
},
}),
],
// ...
});

// frontend
export const authClient = createAuthClient({
plugins: [
organizationClient({
teams: {
enabled: true,
},
}),
reactStartCookies(),
],
});
// backend
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
database: drizzleAdapter(db, {
provider: 'pg',
schema: authTables,
usePlural: true,
}),
plugins: [
organization({
teams: {
enabled: true,
},
}),
],
// ...
});

// frontend
export const authClient = createAuthClient({
plugins: [
organizationClient({
teams: {
enabled: true,
},
}),
reactStartCookies(),
],
});
export const Route = createFileRoute({
loader: async () => {
const result = await auth.api.listOrganizationTeams({
query: {
organizationId: '',
},
});
return result; // unknown[] | null
},
component: RouteComponent,
});

function RouteComponent() {
const { authClient } = Route.useRouteContext();

const teamsQuery = useQuery({
queryKey: ['teams'],
queryFn: async () => {
const { data, error } = await authClient.organization.listTeams({
query: {
organizationId: '',
},
});
if (error) {
throw error;
}
return data; // unknown[] | null
},
});

return null;
}
export const Route = createFileRoute({
loader: async () => {
const result = await auth.api.listOrganizationTeams({
query: {
organizationId: '',
},
});
return result; // unknown[] | null
},
component: RouteComponent,
});

function RouteComponent() {
const { authClient } = Route.useRouteContext();

const teamsQuery = useQuery({
queryKey: ['teams'],
queryFn: async () => {
const { data, error } = await authClient.organization.listTeams({
query: {
organizationId: '',
},
});
if (error) {
throw error;
}
return data; // unknown[] | null
},
});

return null;
}
Relevant deps:
"@tanstack/react-router": "^1.123.2",
"@tanstack/react-start": "^1.123.2",
"@tanstack/react-table": "^8.21.3",
"@tanstack/router-plugin": "^1.123.2",
"better-auth": "^1.2.12",
"drizzle-orm": "^0.44.2",
"pg": "^8.16.3",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"vite": "^7.0.0",
"@tanstack/react-router": "^1.123.2",
"@tanstack/react-start": "^1.123.2",
"@tanstack/react-table": "^8.21.3",
"@tanstack/router-plugin": "^1.123.2",
"better-auth": "^1.2.12",
"drizzle-orm": "^0.44.2",
"pg": "^8.16.3",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"vite": "^7.0.0",
2 Replies
Ping
Ping4mo ago
Hey @Winston good find, just tested this locally and had the same issue. I'll open a PR and fix it.

Did you find this page helpful?