Type issue when trying to use better-auth in Turborepo

Hi everyone, I'm trying to use better-auth in turborepo and made my own internal package. "@workspace/auth". I am setting up better-auth, but I get this annoying error on my auth.ts and auth-client.ts. How can I fix this?
The inferred type of 'client' cannot be named without a reference to '.pnpm/@simplewebauthn+server@13.0.0/node_modules/@simplewebauthn/server'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'client' cannot be named without a reference to '.pnpm/@simplewebauthn+server@13.0.0/node_modules/@simplewebauthn/server'. This is likely not portable. A type annotation is necessary.ts(2742)
import { createAuthClient } from "better-auth/react";
import {
organizationClient,
passkeyClient,
twoFactorClient,
adminClient,
multiSessionClient,
oneTapClient,
} from "better-auth/client/plugins";
import { ac, owner as ownerRole, admin as adminRole, member as memberRole, myCustomRole } from "@workspace/auth/permissions";
import { toast } from "sonner";

export const client = createAuthClient({
plugins: [
organizationClient({
ac: ac,
roles: {
owner: ownerRole,
admin: adminRole,
member: memberRole,
myCustomRole
}
}),
twoFactorClient({
onTwoFactorRedirect() {
window.location.href = "/two-factor";
},
}),
passkeyClient(),
adminClient(),
multiSessionClient(),
// oneTapClient({
// clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID!,
// }),
],
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error("Too many requests. Please try again later.");
}
},
},
});

export const {
signUp,
signIn,
signOut,
useSession,
organization,
useListOrganizations,
useActiveOrganization,
} = client;
import { createAuthClient } from "better-auth/react";
import {
organizationClient,
passkeyClient,
twoFactorClient,
adminClient,
multiSessionClient,
oneTapClient,
} from "better-auth/client/plugins";
import { ac, owner as ownerRole, admin as adminRole, member as memberRole, myCustomRole } from "@workspace/auth/permissions";
import { toast } from "sonner";

export const client = createAuthClient({
plugins: [
organizationClient({
ac: ac,
roles: {
owner: ownerRole,
admin: adminRole,
member: memberRole,
myCustomRole
}
}),
twoFactorClient({
onTwoFactorRedirect() {
window.location.href = "/two-factor";
},
}),
passkeyClient(),
adminClient(),
multiSessionClient(),
// oneTapClient({
// clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID!,
// }),
],
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error("Too many requests. Please try again later.");
}
},
},
});

export const {
signUp,
signIn,
signOut,
useSession,
organization,
useListOrganizations,
useActiveOrganization,
} = client;
4 Replies
Ping
Ping5mo ago
@salzar Make sure you have strict set to true in your tsconfig.
Ping
Ping5mo ago
salzar
salzarOP5mo ago
After adding these 3, it worked perfect
"strict": true,
"declaration": false,
"declarationMap": false
"strict": true,
"declaration": false,
"declarationMap": false
Ping
Ping5mo ago
Awesome

Did you find this page helpful?