Framework integration
Building or adapting a framework integration around Auth.js Core.
Auth.js · Function
Auth is Auth.js Core’s main request handler: it accepts a Web-standard Request and authentication configuration, then asynchronously returns a Web-standard Response.
Auth is Auth.js Core’s main request handler. It accepts a standard Web Request plus configuration, processes the relevant authentication operation, and asynchronously returns a standard Web Response.
Auth(request, config)| Name | Type | Description |
|---|---|---|
request | Request | A standard Web API Request containing the authentication request. |
config | AuthConfig | Auth.js configuration options used to process the request. |
A Promise resolving to a standard Web Response.
import { Auth } from "@auth/core"
const request = new Request("https://example.com")
const response = await Auth(request, {
secret: process.env.AUTH_SECRET,
trustHost: true,
})
console.log(response instanceof Response)Creates a standard Web Request, passes it to Auth with configuration, and receives a standard Response.
Building or adapting a framework integration around Auth.js Core.
Handling authentication requests directly in a runtime that supports Web APIs.
Testing Auth.js request handling with constructed Request objects.
Auth is the main entry point of Auth.js Core. It receives a Web-standard Request and returns a Web-standard Response asynchronously.
Follow-up: How can a caller verify the result type? The documentation’s example checks that the result is an instance of Response.
Import Auth from @auth/core and call it with the request followed by an Auth configuration object. The configuration can include settings such as providers, secret, and trustHost.
Follow-up: What should be supplied for application-specific authentication behavior? Configure the Auth options object, including the providers and other required settings for the deployment.
Auth is designed as core functionality for Auth.js and is primarily used to build framework-specific packages, although applications can call it directly.
Follow-up: Why is direct use portable? Because the API is based on standard Request and Response Web APIs rather than a framework-specific transport type.
AuthConfigRequestResponseproviderssecrettrustHost