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

Auth.js · Const

Reddit

Auth.js includes Reddit as a built-in OAuth provider. Configure Reddit credentials in NextAuth, and use duration: "permanent" when a refresh token is required.

How it works

The Reddit provider is a built-in OAuth integration. Add it to Auth.js with Reddit credentials; customize authorization parameters when you need a refresh token rather than the provider's default short-lived access token.

Syntax

function default(config): OAuthConfig<Record<string, any>>

Parameters

NameTypeDescription
configOAuthUserConfig<Record<string, any>>Optional Reddit OAuth configuration, including client credentials and authorization overrides.

Returns

OAuthConfig<Record<string, any>>

Key points

  • Auth.js supplies Reddit as a built-in provider rather than requiring a custom OAuth implementation.
  • The Reddit callback endpoint follows the Auth.js API route pattern and ends with the provider identifier reddit.
  • The getting-started page documents AUTH_REDDIT_ID and AUTH_REDDIT_SECRET as the provider environment variables.
  • The provider can be used with its built-in defaults, while explicit options are available for customization.
  • A refresh token requires changing the authorization settings instead of relying on the default provider configuration.

Common mistakes

  • Users must authorize Reddit on every visit through Reddit's authorization page.
  • A Reddit application can have only one callback URL for each credential pair.
  • The default access token lasts one hour, so long-lived access requires additional authorization configuration.

Example: Configure Reddit with refresh-token authorization

import NextAuth from "next-auth"
import Reddit from "next-auth/providers/reddit"

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [
    Reddit({
      clientId: process.env.REDDIT_CLIENT_ID,
      clientSecret: process.env.REDDIT_CLIENT_SECRET,
      authorization: { params: { duration: "permanent" } },
    }),
  ],
})

Configures Reddit sign-in and requests a permanent authorization so Auth.js can obtain a refresh token.

When to use it

Reddit social login

Users need to sign in with Reddit through an Auth.js application.

Refresh-token authorization

The application needs to renew Reddit access after the default token expires.

Built-in OAuth setup

A project wants a standard Reddit OAuth integration without implementing provider endpoints itself.

Interview questions

QHow is Reddit added to a Next.js Auth.js configuration?

The provider is imported from next-auth/providers/reddit and passed to NextAuth through the providers array. Credentials can be supplied explicitly with clientId and clientSecret, or the provider can use the documented environment-variable setup.

Follow-up: How would you obtain a refresh token? Set authorization.params.duration to "permanent" in the Reddit provider configuration.

QWhat callback URL must be configured for Reddit?

The documented callback URL is /api/auth/callback/reddit under the application's origin. That URL must be registered in Reddit's application settings, and Reddit permits only one callback URL per client credential pair.

Follow-up: What deployment constraint follows from that limitation? A single Reddit credential pair cannot directly serve multiple callback URLs.

QWhat are Reddit's default token limitations?

The default template requests only the identity scope and provides a one-hour access token. To request a refresh token, configure the authorization parameter duration as permanent.

Follow-up: Why is this configuration necessary for durable access? Without the permanent duration parameter, the documented default does not provide the refresh-token behavior needed for renewal.

  • OAuthConfig
  • OAuthUserConfig
  • NextAuth
  • authorization
  • duration
  • AUTH_REDDIT_ID
  • AUTH_REDDIT_SECRET

Source: Reddit - Auth.js. Checked 2026-10-15.