Shared application configuration
Create a reusable auth.config.ts module containing providers and other adapter-independent options.
Auth.js · Type Alias
NextAuthConfig is the current Auth.js configuration type for Next.js. Use it to type a reusable configuration object, especially shared options that do not require an adapter.
NextAuthConfig is the configuration type used by Auth.js for shared options. In current Next.js integrations, export a configuration object that satisfies this type; keep it separate from the later NextAuth() call when the configuration must also work in environments such as middleware.
type NextAuthConfig = Omit<AuthConfig, "raw"> | ((request: NextRequest | undefined) => Awaitable<Omit<AuthConfig, "raw">>)A TypeScript configuration object type; it does not create an Auth.js instance.
satisfies operator.import GitHub from "next-auth/providers/github"
import type { NextAuthConfig } from "next-auth"
export default {
providers: [GitHub],
} satisfies NextAuthConfigDefines shared Auth.js configuration as a type-checked object without creating a NextAuth instance.
Create a reusable auth.config.ts module containing providers and other adapter-independent options.
Reuse common authentication settings in middleware or proxy code without loading database-specific adapter dependencies.
NextAuthConfig is the current name for the configuration type previously called NextAuthOptions. It describes the options object passed to or used with the Next.js Auth.js integration.
Follow-up: Why separate an auth.config.ts file from auth.ts? A shared config can be reused in constrained environments, while the full instance can add adapter-dependent configuration.
Use a plain object and apply satisfies NextAuthConfig. This checks that the object conforms to the expected configuration shape while leaving the object as the value exported by the module.
Follow-up: What does satisfies avoid? It avoids turning the expression into a runtime Auth.js instance; it performs TypeScript compatibility checking only.
The shared object should contain common configuration that does not depend on the adapter, such as providers. Adapter and other environment-specific settings belong in the instantiated Auth.js setup when required.
Follow-up: What is the practical benefit? The same provider configuration can be imported by middleware or proxy code without importing database-specific dependencies.
AuthConfigNextAuthNextAuthOptionsAdapter