[GH-ISSUE #5672] Missing the better-auth/cookies in nextjs demo #18951

Closed
opened 2026-04-15 17:41:33 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @A-caibird on GitHub (Oct 30, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5672

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

git clone https://github.com/better-auth/better-auth
cd better-auth/demo/nextjs
pnpm i

Current vs. Expected behavior

   ▲ Next.js 16.0.1 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://192.168.2.181:3000
   - Environments: .env

 ✓ Starting...
 ⨯ ./demo/nextjs/proxy.ts:1:1
Module not found: Can't resolve 'better-auth/cookies'
> 1 | import { getSessionCookie } from "better-auth/cookies";
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2 | import { NextRequest, NextResponse } from "next/server";
  3 |
  4 | export async function proxy(request: NextRequest) {

What version of Better Auth are you using?

latest

System info

macos 26.0, m2 pro

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

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @A-caibird on GitHub (Oct 30, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5672 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce git clone https://github.com/better-auth/better-auth cd better-auth/demo/nextjs pnpm i ### Current vs. Expected behavior ```shell ▲ Next.js 16.0.1 (Turbopack) - Local: http://localhost:3000 - Network: http://192.168.2.181:3000 - Environments: .env ✓ Starting... ⨯ ./demo/nextjs/proxy.ts:1:1 Module not found: Can't resolve 'better-auth/cookies' > 1 | import { getSessionCookie } from "better-auth/cookies"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | import { NextRequest, NextResponse } from "next/server"; 3 | 4 | export async function proxy(request: NextRequest) { ``` ### What version of Better Auth are you using? latest ### System info ```bash macos 26.0, m2 pro ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:41:33 -05:00
Author
Owner

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

It looks like your Next.js demo can’t locate the cookies helper because the module isn’t available where the demo expects it. Here are a few troubleshooting steps:

  1. Verify that your installation is correct. Make sure the better-auth package is installed (check your package.json and node_modules) and that you’re using the release that actually exports the cookies helper. In some recent updates the file structure may have moved, so confirm you’re using a version where getSessionCookie is exposed under better-auth/cookies.

  2. Check the installed version against the documentation. Sometimes demos lag behind changes in the package. If the cookies helper was relocated (for example, moved into a different export or renamed), adjust the import accordingly. For example, you might try importing it from a different path (such as better-auth/next-js or a similar sub-module) if indicated in the release notes or migration guide.

  3. Clean your install (remove node_modules and lockfiles) and reinstall your dependencies. This may ensure that any build and module resolution issues with Turbopack in Next.js 16 are resolved.

  4. If the module still isn’t found, it may be that the demo needs to be updated to match the current package layout. In that case, checking the Better Auth documentation on Next.js integration (which shows how to import getSessionCookie) may provide clues on the correct import path.

These steps should help you resolve the missing module error. Please let me know if you’re still encountering issues after trying these suggestions [1], [2].

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3467150512 --> @better-auth-agent[bot] commented on GitHub (Oct 30, 2025): It looks like your Next.js demo can’t locate the cookies helper because the module isn’t available where the demo expects it. Here are a few troubleshooting steps: 1. Verify that your installation is correct. Make sure the better-auth package is installed (check your package.json and node_modules) and that you’re using the release that actually exports the cookies helper. In some recent updates the file structure may have moved, so confirm you’re using a version where getSessionCookie is exposed under better-auth/cookies. 2. Check the installed version against the documentation. Sometimes demos lag behind changes in the package. If the cookies helper was relocated (for example, moved into a different export or renamed), adjust the import accordingly. For example, you might try importing it from a different path (such as better-auth/next-js or a similar sub-module) if indicated in the release notes or migration guide. 3. Clean your install (remove node_modules and lockfiles) and reinstall your dependencies. This may ensure that any build and module resolution issues with Turbopack in Next.js 16 are resolved. 4. If the module still isn’t found, it may be that the demo needs to be updated to match the current package layout. In that case, checking the Better Auth documentation on Next.js integration (which shows how to import getSessionCookie) may provide clues on the correct import path. These steps should help you resolve the missing module error. Please let me know if you’re still encountering issues after trying these suggestions [[1]](https://github.com/better-auth/better-auth/issues/935), [[2]](https://github.com/better-auth/better-auth/issues/3788). <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@khushalpatel1981 commented on GitHub (Nov 5, 2025):

Facing the same issue +1, Next JS 16, Windows 11

<!-- gh-comment-id:3489903340 --> @khushalpatel1981 commented on GitHub (Nov 5, 2025): Facing the same issue +1, Next JS 16, Windows 11
Author
Owner

@ilyboc commented on GitHub (Nov 12, 2025):

Hey, make sure you build from the root folder of better-auth repo with pnpm build.
It's because the demo project depends on workspace better-auth in its package.json.

<!-- gh-comment-id:3520001424 --> @ilyboc commented on GitHub (Nov 12, 2025): Hey, make sure you build from the root folder of better-auth repo with `pnpm build`. It's because the demo project depends on workspace better-auth in its package.json.
Author
Owner

@swaroopsuthar commented on GitHub (Nov 22, 2025):

@ilyboc, I'm still facing the issue even when building from the root folder. Additionally, when I try to resolve it by manually removing the cookies code, I encounter problems with other Better Auth plugins.

<!-- gh-comment-id:3565914107 --> @swaroopsuthar commented on GitHub (Nov 22, 2025): @ilyboc, I'm still facing the issue even when building from the root folder. Additionally, when I try to resolve it by manually removing the cookies code, I encounter problems with other Better Auth plugins.
Author
Owner

@bytaesu commented on GitHub (Jan 15, 2026):

Closing this issue as it appears to be resolved.

Our demo app uses this without issues, and I'm not able to reproduce it even when setting up a project with create-next-app.

getSessionCookie has caused build error in the past, so this may have been related, but in any case the issue is now closed.

<!-- gh-comment-id:3756183109 --> @bytaesu commented on GitHub (Jan 15, 2026): Closing this issue as it appears to be resolved. Our demo app uses this without issues, and I'm not able to reproduce it even when setting up a project with create-next-app. `getSessionCookie` has caused build error in the past, so this may have been related, but in any case the issue is now closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18951