Auth.js | Typescript (original) (raw)
Auth.js is committed to type-safety, so it’s written in TypeScript and 100% type safe. It comes with its own type definitions to use in your project.
Even if you don’t use TypeScript, IDEs like VS Code will pick this up to provide you with a better developer experience. While you are typing, you will get suggestions about what certain objects/functions look like, and sometimes links to documentation, examples, and other valuable resources.
Philosophy
We have chosen module augmentationover generics as the main technique to type Auth.js resources across your application in case you extend them.
Module Augmentation
Auth.js libraries come with certain interfaces that are shared across submodules and different Auth.js libraries (For example: and will rely on types from ).
Good examples of such interfaces are or . You can use TypeScript’s Module Augmentation to extend these types to add your own properties across Auth.js without having to pass generic all over the place.
Let’s look at extending for example.
Module augmentation is not limited to specific interfaces. You can augment any we’ve defined, here are some of the more common interfaces that you might want to override based on your use case.
Resources
- TypeScript documentation: Module Augmentation
- DigitalOcean: Module Augmentation in TypeScript
- Creating a Database Adapter
Auth.js © Balázs Orbán and Team -
2025