https://github.com/leonardomso/tanstack-better-auth-session.git
A minimal reproduction repository demonstrating an issue with Better Auth session cookies when using the reactStartCookies plugin with session-related plugins in TanStack Start.
Session token cookie not set when using reactStartCookies plugin with session-related plugins in TanStack Start
The session token cookie is not properly set in the browser when combining the reactStartCookies plugin with other session-related plugins (multiSession, lastLoginMethod, oneTap) and/or enabling session cookie cache.
See auth.ts for the configuration and inline comments describing the issue.
git clone <your-repo-url>
cd tanstack-better-auth-test
bun install
# or
npm install
.env.example to .env and fill in the required values:
cp .env.example .env
Required environment variables:
DATABASE_URL: PostgreSQL connection stringBETTER_AUTH_SECRET: Secret key for Better Auth (minimum 32 characters)VITE_BASE_URL: Base URL for your app (e.g., http://localhost:3000)GOOGLE_CLIENT_ID: Google OAuth client IDGOOGLE_CLIENT_SECRET: Google OAuth client secrethttp://localhost:3000/api/auth/callback/google.env file
createdb better_auth_test
Apply the database schema using Better Auth CLI:
npx @better-auth/cli migrate
# or
npx drizzle-kit push
bun run dev
# or
npm run dev
The app will be available at http://localhost:3000
The issue can be reproduced by uncommenting different sections in src/lib/auth.ts:
Configuration 1: All plugins enabled (current state)
multiSession(), lastLoginMethod(), oneTap(), reactStartCookies()reactStartCookies())src/
โโโ lib/
โ โโโ auth.ts # Better Auth configuration (issue reproduction)
โ โโโ db.ts # Drizzle database instance
โ โโโ db/
โ โโโ schema.ts # Database schema (user, session, account, verification)
โโโ routes/ # TanStack Start routes
If you have insights or potential fixes for this issue, please feel free to open a PR or discussion.
MIT