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

Auth.js · Const

Box

Box is a built-in Auth.js OAuth provider. Configure it with Box credentials and add it to the providers array; in Next.js, register the /api/auth/callback/box callback URL.

How it works

Box is a built-in OAuth 2.0 provider for Auth.js. Add the provider to the authentication configuration, provide its client credentials through the documented environment variables, and register the generated callback URL with Box.

Syntax

Box(options): OAuthConfig<Record<string, any>>

Parameters

NameTypeDescription
optionsOAuthUserConfig<Record<string, any>>Optional provider configuration, including OAuth client settings and other overrides.

Returns

OAuthConfig<Record<string, any>>

Key points

  • Auth.js ships Box as a built-in provider rather than requiring a custom OAuth provider implementation.
  • The provider recognizes these environment variables for the Box client ID and client secret.
  • For Next.js, register the /api/auth/callback/box callback endpoint with the Box application.
  • The provider factory accepts options and produces an OAuth configuration for Auth.js.

Common mistakes

  • The provider uses OAuth 2.0 defaults; customize its configuration only when your Box integration requires different settings.

Example: Configure Box with NextAuth

import NextAuth from "next-auth"
import Box from "next-auth/providers/box"

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Box],
})

Registers the built-in Box provider in a Next.js Auth.js configuration.

When to use it

Add Box sign-in

Users authenticate through Box in a Next.js application.

Extend an existing Auth.js configuration

An application already uses Auth.js's provider list.

Customize provider options

A Box integration needs non-default OAuth settings.

Interview questions

QHow do you add Box authentication in a Next.js Auth.js application?

Box is enabled by importing the provider from the framework-specific Auth.js package and placing it in the providers array. In Next.js, the documented form is providers: [Box].

Follow-up: How would you supply credentials? Use the documented AUTH_BOX_CLIENT_ID and AUTH_BOX_CLIENT_SECRET environment variables, or pass provider options when customization is needed.

QWhat callback URL must be registered for Box in Next.js?

The callback URL is https://example.com/api/auth/callback/box for the Next.js integration. That URL must be configured in the Box application settings.

Follow-up: What changes for another supported framework? Use that framework's callback path shown in the provider documentation, such as /auth/callback/box.

QWhat does the Box provider factory accept and return?

The provider has a default configuration and returns an OAuth configuration when invoked with provider options. Its documented function signature accepts an OAuthUserConfig<Record<string, any>> object.

Follow-up: Why might the default be overridden? To change supported OAuth settings for a particular integration, while retaining the built-in provider behavior.

  • OAuthConfig
  • OAuthUserConfig
  • customizing a built-in OAuth provider
  • Box OAuth documentation

Source: Box Provider. Checked 2026-10-15.