Issue in create-t3-turbo better-auth implementation

Hi I used the create t3 turbo fork from: and everything seems to be working fine except for the fact that after signing in I kept getting errors from my trpc functions from expo, saying the request are unauthorized. Upon reading the docs a little bit I added the following to me code:
//@ts-expect-error this is a temporary fix for the type error
const cookies = authClient.getCookie();

if (cookies) {
console.log("COOKIES ADDED");
headers.set("Cookie", cookies);
}
//@ts-expect-error this is a temporary fix for the type error
const cookies = authClient.getCookie();

if (cookies) {
console.log("COOKIES ADDED");
headers.set("Cookie", cookies);
}
this solved the issue. The issue here 2 fold: 1. I am just a little confused because the template gets the token from the getToken function, but the server seems unable to decrypt and use the token properly when I get it from there 2. the function to get cookies gives me the following type error:
eslint: Unsafe assignment of an error typed value.
eslint: Unsafe assignment of an error typed value.
and the expo client config gives me the following error:
ts: Type '{ id: "expo"; getActions(_: BetterFetch, $store: Store): { getCookie: () => string; }; fetchPlugins: { id: string; name: string; hooks: { onSuccess(context: SuccessContext<any>): Promise<...>; }; init(url: string, options: { ...; } | undefined): Promise<...>; }[]; }' is not assignable to type 'BetterAuthClientPlugin'.
Types of property 'getActions' are incompatible.
Type '(_: BetterFetch, $store: Store) => { getCookie: () => string; }' is not assignable to type '($fetch: BetterFetch, $store: Store) => Record<string, any>'.
Types of parameters '_' and '$fetch' are incompatible.
Types of parameters 'options' and 'options' are incompatible.
ts: Type '{ id: "expo"; getActions(_: BetterFetch, $store: Store): { getCookie: () => string; }; fetchPlugins: { id: string; name: string; hooks: { onSuccess(context: SuccessContext<any>): Promise<...>; }; init(url: string, options: { ...; } | undefined): Promise<...>; }[]; }' is not assignable to type 'BetterAuthClientPlugin'.
Types of property 'getActions' are incompatible.
Type '(_: BetterFetch, $store: Store) => { getCookie: () => string; }' is not assignable to type '($fetch: BetterFetch, $store: Store) => Record<string, any>'.
Types of parameters '_' and '$fetch' are incompatible.
Types of parameters 'options' and 'options' are incompatible.
rest of the error and code in reply
3 Replies
Ani
AniOP2w ago
Ani
AniOP2w ago
code:
import { createAuthClient } from "better-auth/react";
import { expoClient } from "@better-auth/expo/client";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
plugins: [
expoClient({
scheme: "expo",
storage: SecureStore,
}),
],
baseURL: "http://localhost:3000",
});

export const { signIn, signOut, useSession } = authClient;
import { createAuthClient } from "better-auth/react";
import { expoClient } from "@better-auth/expo/client";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
plugins: [
expoClient({
scheme: "expo",
storage: SecureStore,
}),
],
baseURL: "http://localhost:3000",
});

export const { signIn, signOut, useSession } = authClient;
luksch42
luksch423d ago
I fixed it. Had multiple versions of better fetch installed @Ani

Did you find this page helpful?