Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Function

Auth

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.

How it works

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.

Syntax

Auth(request, config)

Parameters

NameTypeDescription
requestRequestA standard Web API Request containing the authentication request.
configAuthConfigAuth.js configuration options used to process the request.

Returns

A Promise resolving to a standard Web Response.

Key points

  • Auth serves as the central low-level entry point for Auth.js Core.
  • Its contract is a Web-standard Request in and a Response out.
  • Because the call is awaited, application code should treat handling as asynchronous.
  • The function is imported as a named export from the @auth/core package.
  • The configuration object can declare providers, a secret, and whether the host is trusted.

Common mistakes

  • Pass Web-standard Request objects and handle the returned Web-standard Response rather than framework-specific request or response types.
  • Auth is the low-level core entry point; framework integrations may provide a more convenient wrapper.

Example: Call Auth with a Web Request

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.

When to use it

Framework integration

Building or adapting a framework integration around Auth.js Core.

Direct Web API usage

Handling authentication requests directly in a runtime that supports Web APIs.

Request-level testing

Testing Auth.js request handling with constructed Request objects.

Interview questions

QWhat are the input and output of Auth?

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.

QHow is Auth configured when called directly?

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.

QWhen would an application use Auth directly?

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.

  • AuthConfig
  • Request
  • Response
  • providers
  • secret
  • trustHost

Source: auth/core. Checked 2026-10-15.