[GH-ISSUE #1924] [Expo] useSession does not trigger upon user verifying their email #8974

Closed
opened 2026-04-13 04:13:30 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @dancamdev on GitHub (Mar 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1924

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Initialize an Expo project with better auth as per the documentation
  2. signUp a new user with autoSignInAfterVerification = true and requireEmailVerification = false

Current vs. Expected behavior

As soon as the user signs up you'll see a new session being created with user.emailVerified == false (as expected)

Verify the email by clicking on the link on your email

You'll see the session won't update through the useSession hook.

I'm not sure whether this is intended behavior, but my goal would be to rely on useSession to redirect the user to the home screen upon they reviewing their email.

What version of Better Auth are you using?

1.2.4

Provide environment information

- OS: iOS 18.1

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

// ======= CLIENT ======

export const authClient = createAuthClient({
  baseURL: process.env.EXPO_PUBLIC_BACKEND_URL,
  plugins: [
    expoClient({
      scheme: 'scheme',
      storagePrefix: 'scheme',
      storage: SecureStore,
    }),
    usernameClient(),
  ],
});

// ======= SERVER ======

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg",
  }),
  advanced: {
    generateId: false,
  },
  emailVerification: {
    sendOnSignUp: true,
    autoSignInAfterVerification: true,
    sendVerificationEmail: async ({ user, url, token }, request) => {
      await sendEmail({
        to: user.email,
        subject: "Verify your email address",
        text: `Click the link to verify your email: ${url}`,
      });
    },
  },
  emailAndPassword: {
    enabled: true,
    sendResetPassword: async ({ user, url, token }, request) => {
      await sendEmail({
        to: user.email,
        subject: "Reset your password",
        text: `Click the link to reset your password: ${url}`,
      });
    },
    minPasswordLength: 8,
    maxPasswordLength: 32,
    requireEmailVerification: false,
    autoSignIn: 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, // Cache duration in seconds
    },
  },
  plugins: [expo(), username()],
  trustedOrigins: ["scheme://"],
});

Additional context

No response

Originally created by @dancamdev on GitHub (Mar 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1924 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Initialize an Expo project with better auth as per the documentation 2. signUp a new user with `autoSignInAfterVerification = true` and `requireEmailVerification = false` ### Current vs. Expected behavior As soon as the user signs up you'll see a new session being created with `user.emailVerified == false` (as expected) Verify the email by clicking on the link on your email You'll see the session won't update through the `useSession` hook. I'm not sure whether this is intended behavior, but my goal would be to rely on `useSession` to redirect the user to the home screen upon they reviewing their email. ### What version of Better Auth are you using? 1.2.4 ### Provide environment information ```bash - OS: iOS 18.1 ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript // ======= CLIENT ====== export const authClient = createAuthClient({ baseURL: process.env.EXPO_PUBLIC_BACKEND_URL, plugins: [ expoClient({ scheme: 'scheme', storagePrefix: 'scheme', storage: SecureStore, }), usernameClient(), ], }); // ======= SERVER ====== export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", }), advanced: { generateId: false, }, emailVerification: { sendOnSignUp: true, autoSignInAfterVerification: true, sendVerificationEmail: async ({ user, url, token }, request) => { await sendEmail({ to: user.email, subject: "Verify your email address", text: `Click the link to verify your email: ${url}`, }); }, }, emailAndPassword: { enabled: true, sendResetPassword: async ({ user, url, token }, request) => { await sendEmail({ to: user.email, subject: "Reset your password", text: `Click the link to reset your password: ${url}`, }); }, minPasswordLength: 8, maxPasswordLength: 32, requireEmailVerification: false, autoSignIn: 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, // Cache duration in seconds }, }, plugins: [expo(), username()], trustedOrigins: ["scheme://"], }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:13:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8974