CapnCrunch
CapnCrunch
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
Beautiful 1.1.18 works
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
Thank you for the help I'll try 1.1.18 in the meantime
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
No description
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
updated no errors from the terminal, but the app loads fine and after a second i get this on devtools
console.js:614 TypeError: Cannot read property 'subtle' of undefined, js engine: hermes Error Component Stack:
at ContextNavigator (ExpoRoot.js:73:36)
at ExpoRoot (ExpoRoot.js:47:76)
at App (<anonymous>)
at ErrorToastContainer (ErrorToastContainer.tsx:4:11)
at ErrorOverlay (<anonymous>)
at withDevTools(ErrorOverlay) (withDevTools.ios.tsx:27:25)
at RCTView (<anonymous>)
at View (View.js:32:34)
at CssInterop.View (api.js:32:48)
at RCTView (<anonymous>)
at View (View.js:32:34)
at CssInterop.View (api.js:32:48)
at AppContainer (AppContainer-dev.js:87:11)
at main(RootComponent) (getCachedComponentWithDebugName.js:26:42)
console.js:614 TypeError: Cannot read property 'subtle' of undefined, js engine: hermes Error Component Stack:
at ContextNavigator (ExpoRoot.js:73:36)
at ExpoRoot (ExpoRoot.js:47:76)
at App (<anonymous>)
at ErrorToastContainer (ErrorToastContainer.tsx:4:11)
at ErrorOverlay (<anonymous>)
at withDevTools(ErrorOverlay) (withDevTools.ios.tsx:27:25)
at RCTView (<anonymous>)
at View (View.js:32:34)
at CssInterop.View (api.js:32:48)
at RCTView (<anonymous>)
at View (View.js:32:34)
at CssInterop.View (api.js:32:48)
at AppContainer (AppContainer-dev.js:87:11)
at main(RootComponent) (getCachedComponentWithDebugName.js:26:42)
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
auth.ts on my nextjs folder
import { expo } from "@better-auth/expo";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { nextCookies } from "better-auth/next-js";

import { db } from "@acme/db";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "mysql",
}),
trustedOrigins: ["exp://"],
emailAndPassword: {
enabled: true,
},
session: {
expiresIn: 60 * 60 * 24 * 7, // 7 days
updateAge: 60 * 60 * 24, // 1 day (every 1 day the session expiration is updated)
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24 * 7, // 7 days
},
},
user: {
additionalFields: {
phone: {
type: "string",
required: true,
},
role: {
type: "string",
required: true,
default: "client",
validate: (value: string) =>
["client", "admin", "member"].includes(value),
},
},
},
rateLimit: {
window: 60, // time window in seconds
max: 5, // max requests in the window
},
plugins: [
expo(),
nextCookies(), // make sure this is the last plugin in the array
],
});

export type Session = typeof auth.$Infer.Session;
import { expo } from "@better-auth/expo";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { nextCookies } from "better-auth/next-js";

import { db } from "@acme/db";

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "mysql",
}),
trustedOrigins: ["exp://"],
emailAndPassword: {
enabled: true,
},
session: {
expiresIn: 60 * 60 * 24 * 7, // 7 days
updateAge: 60 * 60 * 24, // 1 day (every 1 day the session expiration is updated)
cookieCache: {
enabled: true,
maxAge: 60 * 60 * 24 * 7, // 7 days
},
},
user: {
additionalFields: {
phone: {
type: "string",
required: true,
},
role: {
type: "string",
required: true,
default: "client",
validate: (value: string) =>
["client", "admin", "member"].includes(value),
},
},
},
rateLimit: {
window: 60, // time window in seconds
max: 5, // max requests in the window
},
plugins: [
expo(),
nextCookies(), // make sure this is the last plugin in the array
],
});

export type Session = typeof auth.$Infer.Session;
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
import * as SecureStore from "expo-secure-store";
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";
import { inferAdditionalFields } from "better-auth/client/plugins";
import type { auth } from "@acme/auth";

export const authClient = createAuthClient({
baseURL: "http://localhost:3000",
plugins: [
expoClient({
scheme: "pp-app",
storagePrefix: "pp-app",
storage: SecureStore,
}),
inferAdditionalFields<typeof auth>(),
],
});
import * as SecureStore from "expo-secure-store";
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";
import { inferAdditionalFields } from "better-auth/client/plugins";
import type { auth } from "@acme/auth";

export const authClient = createAuthClient({
baseURL: "http://localhost:3000",
plugins: [
expoClient({
scheme: "pp-app",
storagePrefix: "pp-app",
storage: SecureStore,
}),
inferAdditionalFields<typeof auth>(),
],
});
Also get this in the console
WARN Attempted to import the module "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/ciphers/crypto.js" which is not listed in the "exports" of "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/ciphers" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.
WARN Attempted to import the module "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/hashes/crypto.js" which is not listed in the "exports" of "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/hashes" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.
The package at "node_modules/jose/dist/node/esm/runtime/base64url.js" attempted to import the Node standard library module "node:buffer".
It failed because the native React runtime does not include the Node standard library.
WARN Attempted to import the module "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/ciphers/crypto.js" which is not listed in the "exports" of "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/ciphers" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.
WARN Attempted to import the module "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/hashes/crypto.js" which is not listed in the "exports" of "/Users/gabo/development/ppsolutions/monorepo/node_modules/@noble/hashes" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.
The package at "node_modules/jose/dist/node/esm/runtime/base64url.js" attempted to import the Node standard library module "node:buffer".
It failed because the native React runtime does not include the Node standard library.
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
1.1.19
17 replies
BABetter Auth
Created by CapnCrunch on 2/23/2025 in #help
Infer Additional fields
Thank you for the help!
import { inferAdditionalFields } from "better-auth/client/plugins";
import { inferAdditionalFields } from "better-auth/client/plugins";
Yep if I add the plugin to the plugins array, i get the error removing it solves it. I'll dig around aswell
17 replies