import { DefaultSession } from "next-auth";declare module "next-auth" { interface Session { user: { id: string; } & DefaultSession["user"]; }}
Like this code, we inject the user object inside next-auth
while using this while accessing session.user.id
TypeScript
does not complain about type.I am using app router and next version is "next": "14.0.4"