Upgrading from 1.4 beta to 1.4.5 : cannot use oauthConfig inside advanced #2446

Closed
opened 2026-03-13 09:55:16 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @realtebo on GitHub (Dec 3, 2025).

import { betterAuth } from "better-auth";
import { nextCookies } from "better-auth/next-js";

....

export const auth = betterAuth({
  appName: "my projecy,
  baseURL: AUTH_URL,
  secret: AUTH_SECRET,

  socialProviders: {
    cognito: {
      clientId: AUTH_COGNITO_ID,
      clientSecret: AUTH_COGNITO_SECRET,
      domain: AUTH_COGNITO_DOMAIN,
      region: AUTH_COGNITO_REGION,
      userPoolId: AUTH_COGNITO_USER_POOL_ID,
      scope: ["openid", "profile", "email"],
    },
  },
  session: {
    expiresIn: 60 * 60 * 24 * 7, // 7 days
    cookieCache: {
      enabled: true,
      maxAge: 30 * 24 * 60 * 60, // 30 days
      strategy: "jwt", // or "compact" or "jwe"
      refreshCache: true, // enables fully stateless mode
    },
  },
  advanced: {
    oauthConfig: {
      storeStateStrategy: "cookie",
    },
  },
  plugins: [nextCookies()],
});

I have this error

./src/lib/auth.ts:54:5
Type error: Object literal may only specify known properties, and 'oauthConfig' does not exist in type 'BetterAuthAdvancedOptions'.

  52 |   },
  53 |   advanced: {
> 54 |     oauthConfig: {
     |     ^
  55 |       storeStateStrategy: "cookie",
  56 |     },
  57 |   },
Next.js build worker exited with code: 1 and signal: null

It was working in 1.4.0 beta xxx

Originally created by @realtebo on GitHub (Dec 3, 2025). ``` import { betterAuth } from "better-auth"; import { nextCookies } from "better-auth/next-js"; .... export const auth = betterAuth({ appName: "my projecy, baseURL: AUTH_URL, secret: AUTH_SECRET, socialProviders: { cognito: { clientId: AUTH_COGNITO_ID, clientSecret: AUTH_COGNITO_SECRET, domain: AUTH_COGNITO_DOMAIN, region: AUTH_COGNITO_REGION, userPoolId: AUTH_COGNITO_USER_POOL_ID, scope: ["openid", "profile", "email"], }, }, session: { expiresIn: 60 * 60 * 24 * 7, // 7 days cookieCache: { enabled: true, maxAge: 30 * 24 * 60 * 60, // 30 days strategy: "jwt", // or "compact" or "jwe" refreshCache: true, // enables fully stateless mode }, }, advanced: { oauthConfig: { storeStateStrategy: "cookie", }, }, plugins: [nextCookies()], }); ``` I have this error ``` ./src/lib/auth.ts:54:5 Type error: Object literal may only specify known properties, and 'oauthConfig' does not exist in type 'BetterAuthAdvancedOptions'. 52 | }, 53 | advanced: { > 54 | oauthConfig: { | ^ 55 | storeStateStrategy: "cookie", 56 | }, 57 | }, Next.js build worker exited with code: 1 and signal: null ``` It was working in 1.4.0 beta xxx
GiteaMirror added the bug label 2026-03-13 09:55:16 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 3, 2025):

(tag @better-auth-agent if you would like an answer from the Agent)

If you need more help, tag @Skyvern in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 3, 2025): (tag @better-auth-agent if you would like an answer from the Agent) _If you need more help, tag @Skyvern in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 3, 2025):

This error is due to a breaking change in better-auth 1.4.5: the oauthConfig property is no longer valid inside the advanced section. OAuth state options like storeStateStrategy have moved to the account section of your config.

To fix your config, move those options to account. For example:

export const auth = betterAuth({
  appName: "my project",
  baseURL: AUTH_URL,
  secret: AUTH_SECRET,
  socialProviders: {
    cognito: {
      clientId: AUTH_COGNITO_ID,
      clientSecret: AUTH_COGNITO_SECRET,
      domain: AUTH_COGNITO_DOMAIN,
      region: AUTH_COGNITO_REGION,
      userPoolId: AUTH_COGNITO_USER_POOL_ID,
      scope: ["openid", "profile", "email"],
    },
  },
  session: {
    expiresIn: 60 * 60 * 24 * 7,
    cookieCache: {
      enabled: true,
      maxAge: 30 * 24 * 60 * 60,
      strategy: "jwt",
      refreshCache: true,
    },
  },
  account: {
    storeStateStrategy: "cookie",
    storeAccountCookie: true, // optional, for stateless flows
  },
  plugins: [nextCookies()],
});

The session.cookieCache config remains valid. If you need to skip the state cookie check, use account.skipStateCookieCheck, but be aware this has security implications.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 3, 2025): <!-- Answer --> This error is due to a breaking change in better-auth 1.4.5: the `oauthConfig` property is no longer valid inside the `advanced` section. OAuth state options like `storeStateStrategy` have moved to the `account` section of your config. To fix your config, move those options to `account`. For example: ```ts export const auth = betterAuth({ appName: "my project", baseURL: AUTH_URL, secret: AUTH_SECRET, socialProviders: { cognito: { clientId: AUTH_COGNITO_ID, clientSecret: AUTH_COGNITO_SECRET, domain: AUTH_COGNITO_DOMAIN, region: AUTH_COGNITO_REGION, userPoolId: AUTH_COGNITO_USER_POOL_ID, scope: ["openid", "profile", "email"], }, }, session: { expiresIn: 60 * 60 * 24 * 7, cookieCache: { enabled: true, maxAge: 30 * 24 * 60 * 60, strategy: "jwt", refreshCache: true, }, }, account: { storeStateStrategy: "cookie", storeAccountCookie: true, // optional, for stateless flows }, plugins: [nextCookies()], }); ``` The `session.cookieCache` config remains valid. If you need to skip the state cookie check, use `account.skipStateCookieCheck`, but be aware this has security implications. References: - [Type definitions and migration](https://github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/packages/core/src/types/init-options.ts#L122-L942) - [Official documentation](https://github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/docs/content/docs/reference/options.mdx#L447-L495) - [Session management example](https://github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/docs/content/docs/concepts/session-management.mdx#L166-L275) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/968d3c13-b861-491d-8463-b630d39ed6b1?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20is%20due%20to%20a%20breaking%20change%20in%20better-auth%201.4.5%3A%20the%20%60oauthConfig%60%20property%20is%20no%20longer%20valid%20inside%20the%20%60advanced%60%20section.%20OAuth%20state%20options%20like%20%60storeStateStrategy%60%20have%20moved%20to%20the%20%60account%60%20section%20of%20your%20config.%20%0A%0ATo%20fix%20your%20config%2C%20move%20those%20options%20to%20%60account%60.%20For%20example%3A%0A%0A%60%60%60ts%0Aexport%20const%20auth%20%3D%20betterAuth%28%7B%0A%20%20appName%3A%20%22my%20project%22%2C%0A%20%20baseURL%3A%20AUTH_URL%2C%0A%20%20secret%3A%20AUTH_SECRET%2C%0A%20%20socialProviders%3A%20%7B%0A%20%20%20%20cognito%3A%20%7B%0A%20%20%20%20%20%20clientId%3A%20AUTH_COGNITO_ID%2C%0A%20%20%20%20%20%20clientSecret%3A%20AUTH_COGNITO_SECRET%2C%0A%20%20%20%20%20%20domain%3A%20AUTH_COGNITO_DOMAIN%2C%0A%20%20%20%20%20%20region%3A%20AUTH_COGNITO_REGION%2C%0A%20%20%20%20%20%20userPoolId%3A%20AUTH_COGNITO_USER_POOL_ID%2C%0A%20%20%20%20%20%20scope%3A%20%5B%22openid%22%2C%20%22profile%22%2C%20%22email%22%5D%2C%0A%20%20%20%20%7D%2C%0A%20%20%7D%2C%0A%20%20session%3A%20%7B%0A%20%20%20%20expiresIn%3A%2060%20%2A%2060%20%2A%2024%20%2A%207%2C%0A%20%20%20%20cookieCache%3A%20%7B%0A%20%20%20%20%20%20enabled%3A%20true%2C%0A%20%20%20%20%20%20maxAge%3A%2030%20%2A%2024%20%2A%2060%20%2A%2060%2C%0A%20%20%20%20%20%20strategy%3A%20%22jwt%22%2C%0A%20%20%20%20%20%20refreshCache%3A%20true%2C%0A%20%20%20%20%7D%2C%0A%20%20%7D%2C%0A%20%20account%3A%20%7B%0A%20%20%20%20storeStateStrategy%3A%20%22cookie%22%2C%0A%20%20%20%20storeAccountCookie%3A%20true%2C%20//%20optional%2C%20for%20stateless%20flows%0A%20%20%7D%2C%0A%20%20plugins%3A%20%5BnextCookies%28%29%5D%2C%0A%7D%29%3B%0A%60%60%60%0A%0AThe%20%60session.cookieCache%60%20config%20remains%20valid.%20If%20you%20need%20to%20skip%20the%20state%20cookie%20check%2C%20use%20%60account.skipStateCookieCheck%60%2C%20but%20be%20aware%20this%20has%20security%20implications.%0A%0AReferences%3A%20%20%0A-%20%5BType%20definitions%20and%20migration%5D%28https%3A//github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/packages/core/src/types/init-options.ts%23L122-L942%29%20%20%0A-%20%5BOfficial%20documentation%5D%28https%3A//github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/docs/content/docs/reference/options.mdx%23L447-L495%29%20%20%0A-%20%5BSession%20management%20example%5D%28https%3A//github.com/better-auth/better-auth/blob/bd98735f2a0e63a954f71055e3125cda70cc5b05/docs/content/docs/concepts/session-management.mdx%23L166-L275%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6489)
Author
Owner

@realtebo commented on GitHub (Dec 3, 2025):

Yes, this works.

@realtebo commented on GitHub (Dec 3, 2025): Yes, this works.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2446