EgeOnder
EgeOnder
BABetter Auth
Created by EgeOnder on 3/4/2025 in #help
[1.2.2] Type error with Expo client plugin
I added this code block as a temporary workaround to beat the type error for now
import type { BetterFetchPlugin } from "better-auth/react";
import * as SecureStore from "expo-secure-store";
import { expoClient as originalExpoClient } from "@better-auth/expo/client";
import { magicLinkClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const expoClient = (config: any) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const client = originalExpoClient(config);

return {
...client,
fetchPlugins: client.fetchPlugins.map((plugin) => ({
...plugin,
init: async (url: string, options?: RequestInit) => {
const result = await plugin.init(url, options);
return {
...result,
options: {
...result.options,
signal: result.options?.signal ?? undefined,
},
};
},
})) as BetterFetchPlugin[],
};
};

export const authClient = createAuthClient({
baseURL: getBaseUrl() + "/api/auth",
plugins: [
expoClient({
scheme,
storagePrefix: scheme,
storage: SecureStore,
}),
magicLinkClient(),
],
});
import type { BetterFetchPlugin } from "better-auth/react";
import * as SecureStore from "expo-secure-store";
import { expoClient as originalExpoClient } from "@better-auth/expo/client";
import { magicLinkClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const expoClient = (config: any) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const client = originalExpoClient(config);

return {
...client,
fetchPlugins: client.fetchPlugins.map((plugin) => ({
...plugin,
init: async (url: string, options?: RequestInit) => {
const result = await plugin.init(url, options);
return {
...result,
options: {
...result.options,
signal: result.options?.signal ?? undefined,
},
};
},
})) as BetterFetchPlugin[],
};
};

export const authClient = createAuthClient({
baseURL: getBaseUrl() + "/api/auth",
plugins: [
expoClient({
scheme,
storagePrefix: scheme,
storage: SecureStore,
}),
magicLinkClient(),
],
});
38 replies
BABetter Auth
Created by EgeOnder on 3/4/2025 in #help
[1.2.2] Type error with Expo client plugin
Hey @zenbb , sorry to ping you directly but is there any progress on your part? I still get the same error so I was wondering if you've figured out what is wrong.
38 replies
BABetter Auth
Created by EgeOnder on 3/4/2025 in #help
[1.2.2] Type error with Expo client plugin
I have a monorepo so this is the tsconfig for the Expo app:
// apps/mobile/tsconfig.json

{
"extends": ["@app/tsconfig/base.json"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
},
"jsx": "react-native",
"types": ["nativewind/types"],
"checkJs": false,
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"include": [
"src",
"*.ts",
"*.js",
".expo/types/**/*.ts",
"expo-env.d.ts",
"nativewind-env.d.ts"
],
"exclude": ["node_modules"]
}
// apps/mobile/tsconfig.json

{
"extends": ["@app/tsconfig/base.json"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
},
"jsx": "react-native",
"types": ["nativewind/types"],
"checkJs": false,
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"include": [
"src",
"*.ts",
"*.js",
".expo/types/**/*.ts",
"expo-env.d.ts",
"nativewind-env.d.ts"
],
"exclude": ["node_modules"]
}
And this is the extended base config:
// tooling/tsconfig/base.json

{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ES2022",
"lib": ["ES2022"],
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,

"incremental": true,
"disableSourceOfProjectReferenceRedirect": true,
"tsBuildInfoFile": "${configDir}/.cache/tsbuildinfo.json",

"strict": true,
"noUncheckedIndexedAccess": true,
"checkJs": true,

"jsx": "react-jsx",

"module": "Preserve",
"moduleResolution": "Bundler",
"noEmit": true
},
"exclude": ["node_modules", "build", "dist", ".next", ".expo"]
}
// tooling/tsconfig/base.json

{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ES2022",
"lib": ["ES2022"],
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,

"incremental": true,
"disableSourceOfProjectReferenceRedirect": true,
"tsBuildInfoFile": "${configDir}/.cache/tsbuildinfo.json",

"strict": true,
"noUncheckedIndexedAccess": true,
"checkJs": true,

"jsx": "react-jsx",

"module": "Preserve",
"moduleResolution": "Bundler",
"noEmit": true
},
"exclude": ["node_modules", "build", "dist", ".next", ".expo"]
}
38 replies