Skip to content

Declare module "next-auth/jwt" in next-auth@v5.0.0-beta.22  #12094

Description

@ev0clu

Environment

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 18.36 GB / 31.26 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
  Browsers:
    Brave Browser: 129.1.70.126
  npmPackages:
    @auth/prisma-adapter: ^2.7.2 => 2.7.2 
    next: 14.2.15 => 14.2.15 
    next-auth: ^5.0.0-beta.22 => 5.0.0-beta.22 
    react: ^18 => 18.3.1 

Reproduction URL

https://github.com/nextauthjs/next-auth/blob/main/apps/examples/nextjs/auth.ts

Describe the issue

I use 5.0.0-beta.22. and got the following typescript error when I want to declare new module for auth.ts as the example shows in the auth.js repository.

Invalid module name in augmentation, module 'next-auth/jwt' cannot be found.

declare module "next-auth/jwt" {
  interface JWT {
    accessToken?: string
  }
}

image

How to reproduce

I use the auth.js example to config auth.ts. The example code gives me typescript error.

image

Expected behavior

Typescript should recognize the 'next-auth/jwt' module or define it directly with auth module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalid reproductionThe issue did not have a detectable valid reproduction URLtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions