nextauthjs / nextauthjs/next-auth

Custom login page is not working when using turbopack (nextjs v15)

Open
#13,353 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Environment
  System:
    OS: Linux 6.8 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 21.08 GB / 31.06 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.17.0 - /run/user/1000/fnm_multishells/117412_1767514956193/bin/node
    npm: 10.9.2 - /run/user/1000/fnm_multishells/117412_1767514956193/bin/npm
  Browsers:
    Chrome: 143.0.7499.169
    Firefox: 146.0.1
    Firefox Developer Edition: 146.0.1
  npmPackages:
    next: 15.5.9 => 15.5.9 
    next-auth: ^5.0.0-beta.30 => 5.0.0-beta.30 
    react: 19.2.3 => 19.2.3 
Reproduction URL

https://test-next-auth-theta.vercel.app/

Describe the issue

After building an app using next-auth@beta + NextJS v15 + Turbopack, the console shows an error when the custom login page is shown. It uses a custom login page

If you use it using npm run dev everything works very well. But if you run npm run build and npm run start the browser console shows an error like the attached image

Image

I believe it's a problem when building with turbopack because it's working when you're not using it.

Repository is available here

How to reproduce
  1. Build the app: npm run build
  2. Serve it npm run start
  3. Go to: localhost:3000, the app will redirect you to /signin
  4. The page is not rendered properly and it shows errors on the browser console
Expected behavior

The login page should be shown properly and we should be able to log in

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and follow the reported flow to /signin. Compare npm run dev with npm run build followed by npm run start, then inspect the browser console and the custom login page behavior. Done means the login page renders correctly in the production build and allows sign-in without console errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, react, typescript
Domain
authentication, build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.