luksch42
BABetter Auth
•Created by luksch42 on 1/2/2025 in #help
getCookie() does not exist on authClient - Expo plugin errors
getCookie() does not exist on authClient and I'm getting errors from the expoClient plugin. I tried different versions but no luck.. Anyone experiencing similar or is it my fault?
import { config } from "@/config";
import { expoClient } from "@better-auth/expo/client";
import { organizationClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import Constants from "expo-constants";
import * as SecureStore from "expo-secure-store";
const scheme = Constants.expoConfig?.scheme;
if (typeof scheme !== "string") {
throw new Error("Expo scheme is not set");
}
const authClient = createAuthClient({
baseURL: config.serverBaseUrl,
plugins: [
expoClient({
scheme,
storage: SecureStore,
}),
organizationClient(),
],
});
export { authClient };
---
Property 'getCookie' does not exist on type '{ signIn: { social: <FetchOptions extends { method?: string | undefined; cache?: RequestCache | undefined; credentials?: RequestCredentials | undefined; headers?: (HeadersInit & (HeadersInit | CommonHeaders)) | undefined; ... 30 more ...; disableValidation?: boolean | undefined; }>(data_0: Prettify<...>, data1?: Fe...'.
---
Type '{ id: "expo"; getActions(: BetterFetch, $store: Store): { getCookie: () => string; useSession: () => any; }; fetchPlugins: { id: string; name: string; hooks: { onSuccess(context: SuccessContext<...>): Promise<...>; }; init(url: string, options: { ...; } | undefined): Promise<...>; }[]; }' is not assignable to type 'BetterAuthClientPlugin'.
Types of property 'fetchPlugins' are incompatible.28 replies
BABetter Auth
•Created by luksch42 on 12/12/2024 in #help
empty session in custom plugin hook
I wanna hook into the organization endpoints but the session property is null. I'm authenticated and the cookie is present in the request headers too. Am I missing something?
import type { BetterAuthPlugin } from "better-auth";
import { posthog } from "@.../posthog";
import { createAuthMiddleware } from "better-auth/plugins";
export const posthogPlugin = () =>
({
id: "posthogPlugin",
hooks: {
after: [
{
matcher: ({ path }) => {
if (path === "/organization/create") {
return true;
}
return false;
},
handler: createAuthMiddleware(async (ctx) => {
console.log("hello from handler");
console.log("ctx.context.session", ctx);
if (!ctx.context.session) {
return;
}
console.log("organization_create", ctx.context.session);
posthog.capture({
distinctId: ctx.context.session.user.id,
event: "organization_create",
});
}),
},
],
},
}) satisfies BetterAuthPlugin;
2 replies
BABetter Auth
•Created by luksch42 on 12/11/2024 in #help
Organizations database hooks
Im currently integrating PostHog and used the database hooks to track auth related events. Is there a way to hook into the organizations plugin?
7 replies
BABetter Auth
•Created by luksch42 on 10/22/2024 in #bug-reports
'import.meta' is currently unsupported, js engine: hermes [Component Stack]
…import {env as p} from “std-env”;
I’m getting this in an Expo/React Native project. The Metro Bundler has no import.meta support yet and it seems like this could take a while
5 replies
BABetter Auth
•Created by luksch42 on 10/19/2024 in #bug-reports
Google SSO not working
Social auth with google is currently not working for me.
In my production environment and same for demo.better-auth.com/sign-in
24 replies