Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylor-lindores-reeves/dd0274d0a86cc17a3b52d40d2d4cfe4c to your computer and use it in GitHub Desktop.
Save taylor-lindores-reeves/dd0274d0a86cc17a3b52d40d2d4cfe4c to your computer and use it in GitHub Desktop.
auth.d.ts
import { DefaultSession } from "@auth/core/types";
declare module "@auth/core" {
interface Session {
user: {
email: string;
subscribed: boolean;
// By default, TypeScript merges new interface properties and overwrite existing ones. In this case, the default session user properties will be overwritten, with the new one defined above. To keep the default session user properties, you need to add them back into the newly declared interface
} & DefaultSession["user"]; // To keep the default types
}
}
declare module "@auth/core/adapters" {
interface AdapterUser {
stripeCustomerId: string;
credits: number;
}
}
declare module "next-auth" {
/**
* Leveraged by session callback's user object (AdapterUser extends User)
*/
export interface User extends DefaultUser {
stripeCustomerId: string;
credits: number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment